network_mode details
tags: learning linux networking
content
- when a service uses
network_mode: container:<name>, it uses the samenetwork namespaceof another container, which means:- same ip address
- same localhost
- if there’s a service running on
127.0.0.1:80, either container can access with this ip:port network_modehas an implicit dependency- the one that has
network_modedepends on the one in the value
- the one that has
- one container can have multiple sidecars
- below,
sidecardepends onweband usesweb’s network stack
services:
web:
image: nginx
sidecar:
image: busybox
network_mode: "container:web"
sidecar2:
image: alpine
network_mode: "container:web"