Indeed, I was referring to what @rimelek wrote: instead of using the array style, I prefer the map style for readability. Technical it is neither required, nor beneficial, unless you start using yaml anchors.
environment
, labels
and sysctls
can be either array or map style.
I doubt that yaml aliases (that point to an anchor) can be rendered within a string.
An anchor can be a map, a list, or a scaler, and the alias will replace the anchor with exactly that value.
The yaml do not mention that yaml aliases can be rendered withing to be a yaml alias can. The map style allows convient merges:
x-default-envs:
&default-envs
key1: value1
key2: value2
key3: value3
services:
test:
environment:
<<: *default-envs
key1: x
key4: value4
This would result in following environments:
I just used environments as an example.
Since Swarm deployment where within the scope of your first post, a following up on swarm topics is in scope of the topic. I don’t feel that we necessarily have to create a new topic for it.
Since you already use network_mode: service:protonvpn
, it should work like this in swarm as well. Though setting the network_mode
ultimately means the container can not be part of another docker network.
It really depends on what the application needs and supports. Just because container make it easy to run replicas,
What happens if a request uses a different replica each time? Will the frontend and vpn connection be able to cope with it? Do the replicas need to share state?
It can be hard, brittle or even impossible to run an application that is supposed to be operated as a highlander (as in “there can only be one”).