Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind the published port to specific eth[x] in docker swarm mode

I'm trying to deploy my container to docker swarm cluster(docker engine 1.12.1).

The features of docker swarm mode really are exciting, such as clustering docker, multi-host networking.

However I find something can't be archived in swarm mode so far(docker 1.12.x), which works well when using docker run to start container.

My host has eth0 for Intranet network, eth1 for Internet network. I would like to only publish the service deployed by docker service create on Intranet network. But the service would listen both eth0 and eth1 interfaces after creating the service via docker service create --name my_web --publish 8000:80 my_web_image.

Any solution/workaround to archive the my_web service only listening on eth0 interface?

like image 308
Kane Avatar asked Sep 13 '16 13:09

Kane


People also ask

What is publish port in docker?

Expose means to open the port on the container side, publish means to open it on the Docker host to the outside world. For example, if your docker run command had -p 80:8080, it's exposing port 8080 on the container and publishing port 80 on the host.

Which of the following commands will publish a service's port but only on nodes that are running a task for that service?

To publish a service's port directly on the node where it is running, use the mode=host option to the --publish flag.


1 Answers

Unfortunately, it seems like this is currently not supported.

like image 76
omallo Avatar answered Sep 30 '22 16:09

omallo