Docking containers in real life

I have been following tutorials and experimenting with Docker for several days, but I can’t find an example of using the “real world”.

How can I contact my container outside?

All the examples that I can find end with 1 or more containers, they can share ports with theirs-others, but no one outside the host gets access to open ports.

Doesn't it all make sense to have containers such that at least 1 of them should be accessible from the outside?

I found a tool called pipework ( https://github.com/jpetazzo/pipework ) that will probably help me with this. But is it a tool that everyone is testing Docker for production, what do they use?

Is it a “hack” to make outside talk to my container?

+4
source share
2 answers

You can use the argument -pto open the port of your container on the host machine.

For example:

  sudo docker run -p80:8080 ubuntu bash

Associates port 8080 of your container with port 80 of the host machine.

Therefore, you can access your container from the outside using the host url:

  http://you.domain -> losthost:80 -> container:8080

Is that what you wanted to do? Or maybe I missed something.

(The parameter -exposedisplays only the port in other containers (not the host))

+5
source

Source: https://habr.com/ru/post/1525017/


All Articles