Docker Community Forums

Share and learn in the Docker community.

Binding a container to specific network (instead of 0.0.0.0)

Hi,

I’m trying to link a container/service only to a specific overlay network instead of all. This is a proxy use case.

For example:

fe_nginx:
image: nginx
ports:
- "80"
networks:
- backend
- frontend
deploy:
placement:
constraints: [node.hostname == worker1]
replicas: 2
update_config:
parallelism: 2
delay: 2s
restart_policy:
condition: on-failure

The container is listening on network frontend and backend (0.0.0.0:80 inside the container)

I want to container to only listen on fronted and only use backend ONLY to connect to backend services.

Any thoughts on this?