Docker Community Forums

Share and learn in the Docker community.

How to indicate host interface in docker-compose version 3.3?

Good afternoon everyone.

forgive me, I do not know if the post would be good here.

I’m doing a cluster of two raspberry pi with docker using docker-compose.

But I need to know how to put in the compose that is used in host mode the services.

This is my compose:

<! - begin snippet: js hide: false console: true babel: false ->

<! - language: lang-html ->

 version: "3.4"

 services:
   miservicio_dhcp:
     image: blanrok / dhcpins2
     ports:
       - 67:67
       - 68:68
     tty: true

   miservicio_dns:
     image: blanrok / dnsins2
     ports:
       - 53:53
     tty: true

<! - end snippet ->

Regards, I await your response :), thank you.

Hi

Is it this you’re looking for?

Swarm does not allow to specifify the host interface, though you can map ports and either use ingess or the hosts port (see: https://docs.docker.com/compose/compose-file/#long-syntax-1) to expose your container.

For docker-compose 2.x deployment (as in: not swarm) you can additionaly bind the host port to an ip. Since swarm might schedule the port on any node, there is no way to bind a host port to an ip.

docker-compose allows more of the ‘dirty stuff’ (override ulimits, start containers in privilaged mode and other low level stuff) that Swarm does not support (yet). If you still want multi-container on multi-node deployments, you might want to switch to kubernetes, which allows ever dirtier stuff then docker-compose can even dream of :wink:

1 Like

yes, but I have been reading in the docker documentation and the “network_mode” parameter when I use the docker stack command deply compose-file = docker-compose.yml, I answered that network_mode is not supported. How could I use a parameter equivalent to network_mode: host, or what alternative is there?

Thank you

I understand that you didn’t like the responsen, though let me repeat myself: it is not possible with Docker Swarm.

If you would have read the documentation completly, you should have read that “network_mode” is not supported for Swarm Deployments.

meyay. my answer was for terpz, about what he said about docker-compose

Thank you meyay :slight_smile: