1

Im developing a big architecture, split up in to separate parts.

Each parts uses services (eg: redis) and other projects.

I setup an environment where i can run all the services i need in docker containers with appropriate port mapping, so that duplicate services don't clash.

Now this works all fine if i run my own architecture directly on my pc. But now i'm running my architecture also in/as docker containers (preparing for production), and trying to run these in my system. First they where unable to reach the already setup containers (the services). This i solved by running my own architecture docker containers as --network host.

Now all my containers are running great, but i can't seem to reach them when i go to http://localhost:80 (one of the containers is running on port 80). The other containers on other ports are also not reachable in this way. Did i do something wrong? is there a way to reach them?

im running docker on windows 10 pro. (note: docker 1.12.5, updating to 1.12.6 crashes somehow)

3
  • Have you mapped your ports correctly? I understand your application runs in the container on port 80, but it is not clear if you have mapped that port outside the container as well. You should provide more info on how you run your containers. Commented Jan 12, 2017 at 15:41
  • @AlexanderGeorge if i run in network=host do i still need to map ports? Commented Jan 12, 2017 at 15:58
  • @JoelHarkes no mapping needed, but you may need to adjust firewall rules of the host machine, because docker is not doing this in case of network=host. See some interesting details here: dasblinkenlichten.com/docker-networking-101-host-mode Commented Nov 7, 2018 at 9:06

1 Answer 1

2

Using --network host just attaches your host's network interfaces into the containers. It doesn't necessarily allow port traffic through the system firewall.

If you bind the container ports, e.g. run the containers with -p <host_port>:<container_port>, Docker should adjust firewall rules accordingly and make it all work. (When the container stops, it should clean up after itself as well.)

Alternately, you can use Docker overlay networks, which is usually the suggested solution in this case.

First, create a network for your application.

docker network create myapp 

Then, tell each container to use that network.

docker run --network myapp <other options...> 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the firewall notes. I was troubleshooting a "no route to host" problem half a day before I realized that I need to add new firewall rule.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.