I am using Traefik with docker compose.
I am able to reach my docker containers just fine at their traefik hosts. I am even able to ping the hosts from the command line of the containers themselves. However, inside the docker containers, I cannot reach the hosts using python requests or urllib3. It errors out with errno: 113, no route to host.
So for example, I can reach and browse to http://sentry.mydomain from any web browser, so I know that part of traefik and my containers are working.
I can ping sentry.mydomain from from the command line INSIDE any docker container. eg
# docker-compose run web bash
# ping sentry.mydomain
64 bytes from ... (success)
However, from python, INSIDE any docker container I cannot reach sentry.mydomain. even though I was just able to ping it. eg
# docker-compose run web bash
# ping sentry.mydomain
64 bytes from ... (success)
# python
>>> import requests
>>> r = requests.get('http://sentry.mydomain')
# stack trace ... Failed to establish a new connection: [Errno 113] No route to host'))
Examples from docker-compose.yml:
sentry_web:
<<: *defaults
ports:
- "9000:9000"
expose:
- 9000
networks:
- web
- internal
labels:
- "traefik.enable=true"
- "traefik.backend=sentry"
- "traefik.http.routers.sentry.rule=Host(`sentry.mydomain`)"
- "traefik.http.routers.sentry.entrypoints=web"
- "traefik.docker.network=web"
- "traefik.port=9000"
traefik:
image: "traefik:v2.0.0-rc3"
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--accesslog"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
networks:
- web
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"