@ 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.
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).
Network: container
With the network set to
containera 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_modeset service containers network mode. Available values are platform specific, but Compose specification define specific values which MUST be implemented as described if supported:
nonewhich disable all container networking
hostwhich gives the container raw access to host's network interface
service:{name}which gives the containers access to the specified service onlynetwork_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.
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 🤷🏾♂️