Swarm Configs
- Map files/strings stored in Raft Log to any file path in tasks
- Ideal For nginx/mysql/etc. configs
- Now you don't need to custom image or bind-mount to host
- 17.06+ similar to Secrets but can go anywhere in container
- Immutable, so rotation process is key
- Removable once services are removed
- Strings saved to Swarm Raft Log (instant HA)
- Private keys should still use Secrets (RAM disks, enc at rest)
Examples
- Create a new Config from a nginx config
docker config create nginx01 ./nginx.conf
- Creating a Service with a Config
docker service create --config source=nginx01,target=/etc/nginx/conf.d/default.conf
- Creating new Config to replace old
docker config create nginx01 ./nginx.conf
- Updating Service with new Config
docker service update --config-rm nginx01 --config-add source=nginx02,target=/etc/nginx/conf.d/default.conf
Swarm Configs in Stack Files
version: "3.3"
services:
web:
image: nginx
configs:
- source: nginx-proxy
target: /etc/nginx/conf.d/default.conf
configs:
nginx-proxy:
file: ./nginx-app.conf
External links