How to configure a Docker container to be reachable by container_ip:port from outside the host machine?

。_饼干妹妹 提交于 2019-11-30 13:14:45
Manuel Durando

This answer explain exactly what I want to obtain in a very simple way.

The idea is to have different IP addresses on the host machine, for example using IP aliasing on a single network interface and then launch each container specifying the IP address to where they will be reachable in addition to the exposed port (see the linked answer for an example).

It's possible using the docker run --net command.

Official documentation : https://docs.docker.com/articles/networking/#how-docker-networks-a-container

First thing to do would be to create your own bridge using the official tutorial : https://docs.docker.com/articles/networking/#building-your-own-bridge

Or modify the existing one : https://docs.docker.com/articles/networking/#customizing-docker0

Then you will running your container will map his ip address into the table.

If you wanna be specific using the docker run --net=none command will let you configure your docker IP address.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!