Trying out the new "swarm mode", following this. I have created 3 VM's via docker-machine create --driver virtual box <name>
. But how do I open ports on them?
相关问题
- 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
It might work with
docker run -p <public-port>:<internal-port> <image>
executed on the node. However, since you want to run a swarm, I guess it is better to follow a good guide to solve the routing mess here. If you follow the author's suggestions, you need to create a swarm (i.e. the docker host cluster) first by thedocker-machine
commands, e.g.setup swarm with
join the other machines (if there are any) with
where
<yourtoken>
is found in the output of thedocker swarm init
command.Then the author suggests to create a network with something like
and publish the port by defining a service like
In this example, yourdockerimage is running a service internally on port 8000, which is mapped to the docker host port 80. Then, you can access the service e.g. by
Note, you can access the IP address of any Docker swarm node. Docker swarm will do the magic and will route the request to a container of this service, even if you have chosen the IP address of a node no container of this service is running on.