Is there any way to assign the static public IP
to the container. So the container has the public IP. Client can access to container with the IP.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
This should now be possible with docker 1.10 and the new
docker run --ip
option that you now see indocker network connect
.See also Jessie Frazelle's blog post "IPs for all the Things", and pull request docker/docker#19001.
With currently released versions of Docker this isn't possible (without a lot of manual work behind Docker's back), although it is seldom necessary.
Docker exposes network services in containers through the use of port mappings, and port mappings can bind to specific ip addresses on your host. So if you want to have one web server at
192.168.10.10
and another webserver at192.168.10.20
, first make sure this addresses are available on your host:Then start the first container:
And finally start the second container:
In the above commands, the
-p
option is used to bind the port mapping to a particular ip address. Now you have two containers offering a service on the same port (port 80) but on different ip addresses.