Traefik can't find container
maantjemol opened this issue · 4 comments
Hi. I have deployed podify as a docker-compose stack on a debian VM that also runs traefik. When I try to add podify to traefik I can't access it and I get this error:
level=error msg="service \"podify\" error: unable to find the IP address for the container \"/podify-web-1\": the server is ignored" container=web-podify-a8771715d6a01c1a926b2f8f98800c4331a544dd620640bbec2068c5884818e4 providerName=docker
When I run docker inspect
on the web container, it returns this: "IPAddress": "",
I'm new to Traefik, I think I messed something up in the config. My docker-compose.yml:
version: '3.4'
x-app-defaults: &app-defaults
restart: always
environment: &app-env
URL_HOST: https://podify.maantjemol.com
DATABASE_URL: postgres://podify:verysecurepassword@db/podify
REDIS_URL: redis://redis
SECRET_KEY_BASE: SECRET
RAILS_LOG_TO_STDOUT: "yes"
STORAGE_DIR: /storage
INITIAL_USER_EMAIL: example@gmail.com
INITIAL_USER_PASSWORD: verysecurepassword
ENABLE_SIGNUP: "no"
volumes:
- storage:/storage
depends_on:
- db
- redis
services:
web:
<<: *app-defaults
image: maxhollmann/podify:latest
command: start-server
ports:
- 3010:3000
networks:
- proxy
environment:
<<: *app-env
labels:
- "traefik.enable=true"
- "traefik.http.routers.podify.entrypoints=https"
- "traefik.http.routers.podify.rule=Host(`podify.maantjemol.com`)"
- "traefik.http.middlewares.podify-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.podify.middlewares=podify-https-redirect"
- "traefik.http.routers.podify-secure.entrypoints=https"
- "traefik.http.routers.podify-secure.rule=Host(`podify.maantjemol.com`)"
- "traefik.http.routers.podify-secure.tls=true"
- "traefik.http.routers.podify-secure.service=podify"
- "traefik.http.services.podify.loadbalancer.server.port=3000"
- "traefik.http.routers.podify.middlewares=sslheader@docker"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.docker.network=proxy"
worker:
<<: *app-defaults
image: maxhollmann/podify:latest
command: start-worker
environment:
<<: *app-env
db:
image: postgres:12.3
restart: always
environment:
POSTGRES_USER: podify
POSTGRES_PASSWORD: verysecurepassword
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- pgdata:/var/lib/postgresql/data/pgdata
redis:
image: redis:6
restart: always
volumes:
pgdata:
storage:
networks:
proxy:
external: true
Hm, sounds more like an issue with traefik or docker than with podify. Could your traefik docker-compose.yml as well?
Yes! Here it is:
version: "3"
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
environment:
- CF_API_EMAIL=SECRET
- CF_API_KEY=SECRET
# be sure to use the correct one depending on if you are using a token or key
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /root/traefik/data/traefik.yml:/traefik.yml:ro
- /root/traefik/data/acme.json:/acme.json
- /root/traefik/data/config.yml:/config.yml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik-dashboard.local.maantjemol.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=SECRET"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik-dashboard.local.maantjemol.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
- "traefik.http.routers.traefik-secure.tls.domains[0].main=local.maantjemol.com"
- "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.local.maantjemol.com"
- "traefik.http.routers.traefik-secure.service=api@internal"
networks:
proxy:
external: true
One thing I notice is that the web container keeps crashing because it can't connect to the DB & redis, as they're on different networks. Is it running fine for you? Do you get anything if you go directly to port 3010 on your server?
I was indeed the different networks that caused the problem! I put the db and Redis on the same network and it works perfectly. Thank you, I use podify daily and was just setting it up again with traefik, but this solved it :)