*本文基于 apache/superset 镜像6.1.0-dev配套Postgres 17 Redis 7。运营要周报大盘、产品要漏斗转化、老板要「打开浏览器就能看数」——很多团队会先把报表绑在商业 SaaS BI 上按席位 / 按查询量计费看板一多成本就上去数据还得出境或落到第三方租户里合规与安全评审往往过不了。退回 Excel / 本地透视表又慢、难协作、版本满天飞更谈不上统一口径与权限。于是「自己服务器上跑一套开源 BI」成了常见诉求。Apache Superset正是为此而生它是 Apache 软件基金会旗下的开源数据探索与可视化平台现代 BI。你在浏览器里连接 MySQL、PostgreSQL、Presto/Trino 等几乎任意 SQL 数据源用无代码图表构建器拖拽维度与指标做出柱状图、折线图、地图等可视化再拼成可筛选、可分享的交互式仪表盘进阶同学还可以进SQL Lab直接写 SQL 探数、把查询沉淀为数据集。轻量语义层Dataset 上的指标 / 维度让业务与数仓同学能对齐口径而不必每人一份私有 SQL。角色权限Admin / Alpha / Gamma 等适合内网多角色协作。典型落地包括经营与运营看板、自助取数与即席分析、用开源栈部分替代 Tableau / Power BI / 云 BI 的内网场景。本文用 轩辕镜像 加速在 Linux 上用自包含 Docker Compose拉起Superset Postgres Redis无需 clone GitHub固定标签、挂载superset_config.py元数据进 Postgres避免落到默认 SQLite浏览器登录后即可连库出图。镜像页见 apache/superset标签列表见 tags官方介绍见 Superset IntroDocker 构建说明见 Docker Builds。定位说明本文方案适合单机试用 / 小团队体验。官方声明其 Docker Compose 构造不作为生产高可用方案生产请自建 lean 镜像加驱动并考虑 K8s / Helm、外部托管元数据库与备份。当前 Compose未包含 Celery worker定时报表 / 重异步任务能力有限。一、Apache Superset 是什么Apache Superset是 Apache 软件基金会旗下的开源数据探索与可视化平台现代 BI连接几乎任何支持 SQLAlchemy 的数据源在浏览器里做图表、仪表盘与 SQL 查询。能力说明无代码出图Charts / Dashboards拖拽维度指标即可SQL Lab浏览器里写 SQL、探数、保存查询多数据源PostgreSQL、MySQL、Presto 等还可从列表选更多引擎语义层数据集Dataset上定义指标与维度场景运营看板、自助分析、内网 BI 替代部分商业工具数据流本文 Compose浏览器 ──HTTP:8088──▶ superset_app │ ├──元数据──▶ postgres:17必须挂配置勿落 SQLite └──缓存────▶ redis:7 业务库MySQL / PG / …◀── UI「Connect a database」── superset_app1.1 标签怎么选必看依据官方 Docker Builds标签含义本文6.1.0-dev正式版 6.1.0 的dev构建含psycopg2等可连 Postgres 元数据库采用6.1.0/latestlean几乎无数据库驱动连元数据 Postgres 也要自装驱动生产可衍生不作开箱方案latest-dev浮动标签历史上可能滞后不推荐文稿固定版本master/master-dev开发主干不用更多标签见 apache/superset tags。1.2 为什么不用 git clone 官方仓库官方文档常用「clone 仓库 docker-compose-image-tag.yml」。国内大量环境无法稳定访问 GitHub本文改为只写本地docker-compose.yml.envsuperset_config.py镜像全部走轩辕docker.xuanyuan.run/...不依赖clone / Scarf 网关二、环境要求项目建议操作系统Linux x86_64本文 Ubuntu 24.04官方 Compose不支持 WindowsDockerDocker Engine Compose V2docker compose内存建议 ≥48 GB可用CPU无 AVX2 / x86-64-v2 硬性限制正式版镜像支持 amd64 / arm64端口8088Superset Web工作目录/data/superset示例docker--versiondockercompose version若未装 Docker 可用轩辕一键安装脚本bash(wget-qO- https://xuanyuan.cloud/docker.sh)更多见 轩辕镜像使用手册。三、拉取镜像dockerpull docker.xuanyuan.run/apache/superset:6.1.0-devdockerpull docker.xuanyuan.run/library/postgres:17dockerpull docker.xuanyuan.run/library/redis:7实测输出节选Digest: sha256:5822dff49c41fd745ce33e38af502f9c64df30d133aeba148c5d89b35a1004ef Status: Downloaded newer image for docker.xuanyuan.run/apache/superset:6.1.0-dev docker.xuanyuan.run/apache/superset:6.1.0-dev Digest: sha256:a426e44bac0b759c95894d68e1a0ac03ecc20b619f498a91aae373bf06d8508d Status: Downloaded newer image for docker.xuanyuan.run/library/postgres:17 docker.xuanyuan.run/library/postgres:17 Digest: sha256:a8f08480e1f88f2647fed492d1178c06abb0d0c1fbf02c682a61e2f483fb3954 Status: Downloaded newer image for docker.xuanyuan.run/library/redis:7 docker.xuanyuan.run/library/redis:7四、自包含 Compose 部署4.1 创建目录与密钥sudomkdir-p/data/supersetcd/data/superset openssl rand-base6442把输出写入.env勿把示例密钥原样用于生产cat/data/superset/.envEOF SUPERSET_SECRET_KEY请替换为 openssl 输出的随机串 POSTGRES_PASSWORDsuperset ADMIN_USERNAMEadmin ADMIN_PASSWORDadmin ADMIN_EMAILadminexample.com EOF4.2 必须superset_config.py否则元数据落 SQLite仅设置DATABASE_*环境变量时镜像默认仍可能走SQLiteinit 日志会出现Context impl SQLiteImpl。必须挂载配置显式指定 Postgrescat/data/superset/superset_config.pyEOF import os SECRET_KEY os.environ[SUPERSET_SECRET_KEY] SQLALCHEMY_DATABASE_URI ( postgresqlpsycopg2:// f{os.environ[DATABASE_USER]}:{os.environ[DATABASE_PASSWORD]} f{os.environ[DATABASE_HOST]}:{os.environ[DATABASE_PORT]} f/{os.environ[DATABASE_DB]} ) REDIS_HOST os.environ.get(REDIS_HOST, redis) REDIS_PORT os.environ.get(REDIS_PORT, 6379) CACHE_CONFIG { CACHE_TYPE: RedisCache, CACHE_DEFAULT_TIMEOUT: 300, CACHE_KEY_PREFIX: superset_, CACHE_REDIS_HOST: REDIS_HOST, CACHE_REDIS_PORT: REDIS_PORT, CACHE_REDIS_DB: 1, } DATA_CACHE_CONFIG CACHE_CONFIG FILTER_STATE_CACHE_CONFIG CACHE_CONFIG EXPLORE_FORM_DATA_CACHE_CONFIG CACHE_CONFIG class CeleryConfig: broker_url fredis://{REDIS_HOST}:{REDIS_PORT}/0 result_backend fredis://{REDIS_HOST}:{REDIS_PORT}/1 imports (superset.sql_lab, superset.tasks.scheduler) worker_prefetch_multiplier 1 task_acks_late False CELERY_CONFIG CeleryConfig EOF4.3docker-compose.ymlcat/data/superset/docker-compose.ymlEOF x-superset-env: superset-env SUPERSET_CONFIG_PATH: /app/pythonpath/superset_config.py SUPERSET_SECRET_KEY: ${SUPERSET_SECRET_KEY} DATABASE_USER: superset DATABASE_PASSWORD: ${POSTGRES_PASSWORD} DATABASE_HOST: db DATABASE_PORT: 5432 DATABASE_DB: superset REDIS_HOST: redis REDIS_PORT: 6379 services: db: image: docker.xuanyuan.run/library/postgres:17 container_name: superset_db restart: unless-stopped environment: POSTGRES_DB: superset POSTGRES_USER: superset POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: - db_home:/var/lib/postgresql/data healthcheck: test: [CMD-SHELL, pg_isready -U superset -d superset] interval: 10s timeout: 5s retries: 10 redis: image: docker.xuanyuan.run/library/redis:7 container_name: superset_cache restart: unless-stopped volumes: - redis:/data healthcheck: test: [CMD, redis-cli, ping] interval: 10s timeout: 5s retries: 10 superset-init: image: docker.xuanyuan.run/apache/superset:6.1.0-dev container_name: superset_init depends_on: db: condition: service_healthy redis: condition: service_healthy environment: : *superset-env volumes: - ./superset_config.py:/app/pythonpath/superset_config.py:ro user: root restart: no command: - /bin/bash - -c - | set -e superset db upgrade superset fab create-admin \ --username ${ADMIN_USERNAME} \ --firstname Admin \ --lastname User \ --email ${ADMIN_EMAIL} \ --password ${ADMIN_PASSWORD} \ || true superset init superset: image: docker.xuanyuan.run/apache/superset:6.1.0-dev container_name: superset_app depends_on: db: condition: service_healthy redis: condition: service_healthy superset-init: condition: service_completed_successfully ports: - 8088:8088 environment: : *superset-env volumes: - ./superset_config.py:/app/pythonpath/superset_config.py:ro - superset_home:/app/superset_home user: root restart: unless-stopped command: [/app/docker/entrypoints/run-server.sh] volumes: db_home: redis: superset_home: EOF4.4 启动cd/data/supersetdockercompose up-d实测输出[] Running 8/8 ✔ Network superset_default Created ✔ Volume superset_superset_home Created ✔ Volume superset_db_home Created ✔ Volume superset_redis Created ✔ Container superset_cache Healthy ✔ Container superset_db Healthy ✔ Container superset_init Exited ✔ Container superset_app Startedsuperset_init显示 Exited 是正常的它只做一次性初始化db upgrade→ 创建 admin →superset init成功后退出码应为0然后superset_app才会启动。docker compose ps默认可能不列出已退出容器可用docker compose ps -a查看。五、验证启动确认元数据走的是Postgres而不是 SQLitedockerlogs--tail80superset_init|grep-ESQLite|Postgres|postgresql|Admin User|ERROR实测关键行Context impl PostgresqlImpl. Admin User admin created.探测登录页curl-Ihttp://127.0.0.1:8088/login/实测HTTP/1.1 200 OK Server: gunicorn Content-Type: text/html; charsetutf-8浏览器访问http://服务器IP:8088本文截图环境为http://192.168.1.10:8088。六、浏览器登录与日常使用默认管理员与.env一致项值用户名admin密码admin首次登录后建议立即在右上角Settings中修改密码。6.1 登录页打开http://IP:8088输入admin / admin点击Sign in。6.2 登录后首页登录成功进入Home。全新实例下 Dashboards / Charts 为空No results可点 Dashboard/ Chart开始创建。顶部导航Dashboards、Charts、Datasets、SQL。6.3 Dashboards仪表盘顶部点Dashboards进入仪表盘列表。空实例显示 No Data点右上角 Dashboard新建看板之后把图表拖进去即可。6.4 Charts图表Charts页管理所有可视化。点 Chart选择数据集与图表类型后保存保存的图可挂到仪表盘上。6.5 Datasets数据集Datasets是「表 / SQL 结果」到图表之间的语义层。连上数据库后在这里用 Dataset选表或写自定义 SQL再去出图。6.6 SQL Lab写 SQL 探数顶部SQL→SQL Lab。左侧选数据库与 schema点Add开新标签页写 SQL。适合先探数再把结果沉淀为 Dataset / Chart。6.7 连接业务数据库STEP 1在 SQL Lab 或 Settings 中发起连接时会出现Connect a database向导STEP 1 OF 3。可快速选PostgreSQL / Presto / MySQL / SQLite或从下方列表选更多引擎。6.8 填写连接信息STEP 2以 PostgreSQL 为例填写 Host、Port默认 5432、Database name、Username、Password、Display Name再点Connect。连库主机怎么填易踩坑业务库位置Host 怎么写与 Superset同一 Compose 网络内的服务用服务名例如本文元数据库服务名是db但请勿把业务分析库与元数据库混为一谈跑在宿主机上容器内不要用127.0.0.1那是容器自己用宿主机局域网 IP或host.docker.internal视 Docker 版本 / 额外--add-host远程服务器填可达的 IP / 域名并放行防火墙端口连上库之后的推荐路径Connect database → Datasets Dataset→ Charts Chart→ Dashboards Dashboard也可先在SQL Lab写查询再保存为数据集或图表。七、日常运维cd/data/supersetdockercomposepsdockercompose logs-f--tail100supersetdockercompose restartdockercompose down# 保留 named volume元数据不丢dockercompose up-d# docker compose down -v # 会清空 Postgres / Redis / home慎用升级改 Compose 中镜像标签为新版本 →docker compose pull docker compose up -d升级前建议备份 volume。换大版本请先阅读官方 UPDATING.md。八、FAQQ为什么不用 git clone 官方仓库A国内常无法访问 GitHub。本文自包含 Compose 配置文件即可镜像走轩辕加速域。Q为什么必须挂superset_config.pyA不挂时 init 可能出现SQLiteImpl看板与用户落在容器内 SQLitePostgres 白开。挂上后应看到PostgresqlImpl。Qsuperset_init为什么是 ExitedA一次性初始化容器成功即退出属预期行为。用docker inspect superset_init --format {{.State.ExitCode}}确认应为0。Q默认账号密码是什么Aadmin / admin与.env中ADMIN_*一致。请尽快修改。QCPU 有 AVX2 之类要求吗A没有不像 Doris / ES 9.x。正式版镜像支持 amd64 与 arm64。Q能连 MySQL / ClickHouse 吗AUI 支持选多种引擎6.1.0-dev自带部分驱动缺驱动时需按官方文档扩展 lean 镜像或在容器内安装对应 Python 包。Q适合生产吗A本文偏体验。生产需强化SECRET_KEY、外部备份 Postgres、反向代理 HTTPS、按需加 Celery worker并参考官方 K8s / Helm。Q端口 8088 被占用怎么办A改 Compose 映射左侧端口例如18088:8088浏览器改访新端口。九、命令速查# 拉取dockerpull docker.xuanyuan.run/apache/superset:6.1.0-devdockerpull docker.xuanyuan.run/library/postgres:17dockerpull docker.xuanyuan.run/library/redis:7# 目录与启动需已写好 .env / superset_config.py / docker-compose.ymlcd/data/supersetdockercompose up-d# 验证dockerlogs--tail80superset_init|grep-ESQLite|Postgres|Admin Usercurl-Ihttp://127.0.0.1:8088/login/# 浏览器# http://IP:8088 账号 admin / admin# 停止保留数据dockercompose down十、延伸阅读轩辕镜像页apache/superset标签列表apache/superset tags官方介绍Superset IntroDocker 构建与标签Docker BuildsDocker Compose官方Docker Compose轩辕使用手册xuanyuan.cloud/usage总结标签用固定版6.1.0-dev含 Postgres 驱动配套Postgres 17 Redis 7全程轩辕加速。无需 clone GitHub必须挂载superset_config.py确认 init 日志为PostgresqlImpl。superset_initExited属正常浏览器http://IP:8088默认admin / admin。日常路径连库 → Dataset → Chart → Dashboard也可用 SQL Lab 探数。