Docker Community Forums

Share and learn in the Docker community.

How to use the host IP address for docker also

How to use a single IP address for both the host OS, and the Docker container?

Examples:

I want to run several Docker containers side-by-side.

Each container will have its own port 8080.

I need to use a single IP address to access each container, because you can not assign Virtual IP addresses in Azure.

The containers need to be able to piggyback off of the host OS IP address.

At the HTML level, when an end user wants to get to container number 1, port 8081 on the host OS would connect to 8080 on container number 1.

When an end user wants to get to container number 2, port 8082 on the host OS would connect to 8080 on container number 2.

And so on…

Note that I am running CentOS 7, as a standalone server in the Azure cloud.

I am currently starting my containers using the following command syntax:

docker run --privileged --name -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 8081:8080 -p 8001:8000 -d

The Docker container comes up without any errors, but I can not get to the webpage using 8081 or 8001.

Any help or suggestions would be much appreciated.

JCF