Thu. Aug 14th, 2025

## docker-compose.yml

mariadb:
    build: ./mariadb
    environment:
      MARIADB_ROOT_PASSWORD: rootpwd # CHANGE THIS!
      MARIADB_DATABASE: superset
      MARIADB_USER: user
      MARIADB_PASSWORD: userpass
    volumes:
      - ./mariadb/mariadb_data:/var/lib/mysql
      - ./mariadb/init.sql:/docker-entrypoint-initdb.d/init.sql



superset:
      build: ./superset
      container_name: superset
      ports:
        - "8088:8088"
      environment:
        SUPERSET_ENV : production
        SUPERSET_SECRET_KEY: "4c1n2cusLo0utkNSNX5xj++2llNEHbKOIL9nGZrjemSLCCTr/Y7mBRIY"
        PYTHONPATH: /app/pythonpath
        SQLALCHEMY_DATABASE_URI : mysql+pymysql://user:userpass@mariadb:3306/superset
        SQLALCHEMY_TRACK_MODIFICATIONS : "False"
      depends_on:
        - mariadb
      volumes:
        - ./superset/config/superset_config.py:/app/pythonpath/superset_config.py
        - ./superset/superset_home:/app/superset_home
      command: >
        /bin/sh -c "
        superset db upgrade &&
        superset fab create-admin --username admin --firstname Superset --lastname Admin --email [email protected] --password admin || true &&
        superset init &&
        superset run -h 0.0.0.0 -p 8088"
      restart: always
##Dockerfile

FROM apache/superset:latest

USER root
RUN pip install pymysql
USER superset

Ensure SQL user : user has access to superset database

GRANT ALL PRIVILEGES ON superset.* TO 'user'@'%';
FLUSH PRIVILEGES;
EXIT;

After first run change the docker file as follows

  superset:
      build: ./superset
      container_name: superset
      ports:
        - "8088:8088"
      environment:
        SUPERSET_ENV : production
        SUPERSET_SECRET_KEY: "4c1n2cusLo0utkNSNX5xj++2llNEHbKOIL9nGZrjemSLCCTr/Y7mBRIY"
        PYTHONPATH: /app/pythonpath
        SQLALCHEMY_DATABASE_URI : mysql+pymysql://user:pass@mariadb:3306/superset
        SQLALCHEMY_TRACK_MODIFICATIONS : "False"
      depends_on:
        - mariadb
      volumes:
        - ./superset/config/superset_config.py:/app/pythonpath/superset_config.py
        - ./superset/superset_home:/app/superset_home

      command: >  ## Regular run
        /bin/sh -c "
        superset run -h 0.0.0.0 -p 8088"
      restart: always

Issues and Resolutions

  1. Mariadb not recognized and Superset using sqllite.db
    • Make sure SQL user name and password using in docker compose file is not root. should be a different user.
    • Ensure <<sql user>> used in docker compose file has full privilege’s on superset db.
    • Dont use mysql , pymysql sql works good with superset and make sure pymysql is installed using docker file.
    • Incase of bind volume make sure the folder is deleted before docker compose up command is executed. If the folder is available then the old sqllite db will be loaded
    • Follow the sequence
      • Delete any bind folder
      • docker compose down superset -v
      • docker compose build superset –no-cache
      • docker compose up superset –build

Frequently used Commands

docker-compose down       # Keeps volumes
docker-compose down -v    # ❌ Deletes named volumes
docker volume ls          # List all volumes
docker logs <superset_container_name>

docker compose exec -it superset bash  # supserset container

docker volume prune -f 

## Remove superset volume manually
docker volume rm superset_superset_home
docker volume rm superset_mariadb_data


##Clean superset environment
# Stop and remove containers, networks, and volumes
docker-compose down -v --remove-orphans

# Remove all unused volumes (optional but aggressive)
docker volume prune -f

# Remove dangling images (optional)
docker image prune -f



sudo chown -R 1000:1000 superset_home   ## Ensure for bind volume superset has access

chmod -R 777 superset_home  ## Grant full access



  

By jovaan

Leave a Reply

Your email address will not be published. Required fields are marked *