docker - Unable to curl from one container to another -
i have 2 containers in 1 docker-compose.yml. both on same on same network. have added dependency using "depends_on", able ping other container, curl not working.
version: "2.1" services: web: restart: build: context: . dockerfile: web.dockerfile ports: - "9000:8080" expose: - "8080" networks: - test nginx_web: restart: build: context: . dockerfile: nginx_web.dockerfile ports: - "8100:80" expose: - "80" depends_on: - web networks: - test networks: test:
when trying ping nginx_web container web, working fine. curl isn't working. getting
curl: (7) failed connect 172.28.0.7 port 8080: connection refused
and when doing curl host machine directly web @ port 9000, working fine.
in django app, change listening on 127.0.0.1 listen on interfaces 0.0.0.0. docker containers own network namespace, can't access container's loopback interface.
also, ports not match. django responding on 9000, container container, need use port 9000. mapping published port happens on docker host. , exposing port doesn't use case.
lastly, host, have ports reversed. it's port on host followed port inside container. "8080:9000".
Comments
Post a Comment