Metabase with docker behind Traefik

I want to deploy metabase in docker behind Traefik, but it's not working. In my docker-compose.deps.yml file, used metabase image like :

  metabase:
      image: metabase/metabase
      restart: unless-stopped
      depends_on:
        - mongo
      ports:
        - '3001:3000'
      volumes:
        - ./infrastructure/metabase:/metabase-data
      environment:
        - MB_DB_FILE=/metabase-data/metabase.db
        # - MB_H2_DB_JDBC_URL=jdbc:h2:file:/metabase-data/metabase.db/metabase.db
      deploy:
        replicas: 1

it's working locally on port 3001. now I set traefik for metabase in docker-compose.deploy.yml like :

  metabase:
    labels:
      - 'traefik.enable=true'
      - 'traefik.frontend.rule=Host: dashboard.{{hostname}}'
      - 'traefik.port=3001'
      - 'traefik.docker.network=lamt_overlay_net'

but i can't access through dashboard.**** URL . how can I run metabase behind traefik so that I can access the URL?

Hi @kayumuzzaman
You'll definitely want to migrate away from H2 if you're using Metabase in production:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html
https://metabase.com/docs/latest/operations-guide/running-metabase-on-docker.html

Seems like something is missing from your configs - where is Traefik configured?
You're telling Traefik to use a specific network, but the Metabase container doesn't seem to be using the same network.
Try looking through this: https://www.digitalocean.com/community/tutorials/how-to-use-traefik-v2-as-a-reverse-proxy-for-docker-containers-on-ubuntu-20-04

Traefik is configured in docker-compose.deploy.yml like :

traefik:
    image: traefik:1.7.30
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /data/traefik/acme.json:/acme.json
      - /var/log/traefik.log:/var/log/traefik.log
    configs:
      - source: traefik.{{ts}}
        target: /etc/traefik/traefik.toml
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.role == manager
    networks:
      - overlay_net

also added domains in traefik.toml :

logLevel = "DEBUG"
defaultEntryPoints = ["http", "https"]
insecureSkipVerify = true

[traefikLog]
  filePath = "/var/log/traefik.log"
  format   = "json"

[accessLog]
  filePath = "/var/log/access.log"
  format   = "json"

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  compress = true
  [entryPoints.https.tls]

[api]

[ping]

[docker]
domain = "{{hostname}}"
swarmMode = true
exposedByDefault = false
watch = true

[acme]
email = "xxxx"
storage = "acme.json"
entryPoint = "https"
onHostRule = true

[acme.httpChallenge]
entryPoint = "http"

[[acme.domains]]
  main = "{{hostname}}"
  sans = ["client.{{hostname}}", "gateway.{{hostname}}", "auth.{{hostname}}", "login.{{hostname}}", "api.{{hostname}}", "dashboard.{{hostname}}"]

[retry]

# Enable gzip compression
[http.middlewares]
  [http.middlewares.test-compress.compress]

@kayumuzzaman Traefik is part of overlay_net, but Metabase is not, so how are they supposed to see each other?
I'm sure you can find better help in a Traefik specific forum.

I have added networks: - overlay_net still it's not working, getting 404 not found, what can be the issue? kindly help me with this please.

@kayumuzzaman Did you try to read this guide? Specifically section 3:
https://www.digitalocean.com/community/tutorials/how-to-use-traefik-v2-as-a-reverse-proxy-for-docker-containers-on-ubuntu-20-04#step-3-—-registering-containers-with-traefik

Your problem is not Metabase, but Traefik - you should simplify everything until you got that going with just a simple hello-world example, then you can add https, then Metabase.

Otherwise try with Nginx or Caddy - they are generally easier than Traefik.

the port has to be the internal 3000.

Try this: