Docker.github.io: network_mode: "service:[service name]" not adequately documented.

Created on 23 Oct 2019  ·  3Comments  ·  Source: docker/docker.github.io

@ the docs it reads

Network mode. Use the same values as the docker client --network parameter, plus the special form service:[service name].

But I can't find anything that clearly states what it's supposed to do, just guesses and vague answers.

Same as https://github.com/docker/docker.github.io/issues/5325
But someone closed it and said "feel free to reopen it" but ignored when people asked to reopen.

Most helpful comment

I'm also looking for some documentation on the details of how this feature works. I'm seeing it used in other placements, but I really don't understand the implications of this setting 🤷🏾‍♂️

All 3 comments

I'm currently using network_mode: service: <service_name> in a demo project I'm working on, and from what I can gather, it allows you to define a host container (that connects to a typical docker network), and then you can have 1 or more containers attach to the network stack of the host container.

Useful for service mesh proxy handing with apps running in containers.

Outside of that, I haven't used it otherwise.

I'm also looking for some documentation on the details of how this feature works. I'm seeing it used in other placements, but I really don't understand the implications of this setting 🤷🏾‍♂️

It's pretty vague, but I believe (by reading both the Docker CLI and COMPOSE specification documentation) it is down to docker-compose implementing services which it can reference by name.

Docker CLI references containers directly (by name or id), whereas docker-compose uses services (which as far as I know, under the hood will be translated into containers).

Docker CLI states:

Network: container

With the network set to container a container will share the network stack of another container. The other container’s name must be provided in the format of --network container:<name|id>.

And the COMPOSE specification states:

network_mode

network_mode set service containers network mode. Available values are platform specific, but Compose specification define specific values which MUST be implemented as described if supported:

none which disable all container networking
host which gives the container raw access to host's network interface
service:{name} which gives the containers access to the specified service only

    network_mode: "host"
    network_mode: "none"
    network_mode: "service:[service name]"

I read this as if it implements this on top of the Docker CLI --network options. The service:[name] option is additional and seems to have the same effect as --network container:[name], except that you can refer to a service as defined in a docker-compose file, rather than having to explicitly state the container name.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KantarBruceAdams picture KantarBruceAdams  ·  4Comments

londoncalling picture londoncalling  ·  5Comments

Bharathkumarraju picture Bharathkumarraju  ·  3Comments

AlexOQ picture AlexOQ  ·  4Comments

joaofnfernandes picture joaofnfernandes  ·  3Comments