Service Configuration Reference
build - Configuration options that are applied at build time
-
context - Either a path to a directory containing a Dockerfile, or a url to a git repository
-
dockerfile - Alternate Dockerfile
-
args - Add build arguments, which are environment variables accessible only during the build process
-
cache_from - A list of images that the engine uses for cache resolution
-
labels - Add metadata to the resulting image using Docker labels. You can use either an array or a dictionary.
-
shm_size - Set the size of the/dev/shmpartition for this build's containers. Specify as an integer value representing the number of bytes or as a string expressing a byte value.
-
target - Build the specified stage as defined inside theDockerfile
cap_add, cap_drop
Add or drop container capabilities
command
Override the default command.
configs
Grant access to configs on a per-service basis using the per-serviceconfigsconfiguration.
cgroup_parent
Specify an optional parent cgroup for the container.
container_name
Specify a custom container name, rather than a generated default name.
credential_spec
Configure the credential spec for managed service account.
deploy
Specify configuration related to the deployment and running of services. This only takes effect when deploying to a swarm with docker stack deploy, and is ignored bydocker-compose upanddocker-compose run.
1. endpoint_mode (vip / dnsrr)
Specify a service discovery method for external clients connecting to a swarm.
2. labels
Specify labels for the service. These labels are onlyset on the service, and noton any containers for the service.
3. mode
Eitherglobal(exactly one container per swarm node) orreplicated(a specified number of containers). The default isreplicated.
4. placement
Specify placement of constraints and preferences.
5. replicas
If the service isreplicated(which is the default), specify the number of containers that should be running at any given time.
6. resources
Configures resource constraints.
deploy: resources: limits: cpus: '0.50' memory: 50M reservations: cpus: '0.25' memory: 20M
7. Out Of Memory Exceptions (OOME)
If your services or containers attempt to use more memory than the system has available, you may experience an Out Of Memory Exception (OOME) and a container, or the Docker daemon, might be killed by the kernel OOM killer.
8. restart_policy
Configures if and how to restart containers when they exit. Replaces restart.
- condition - none/on-failure/any (default: any)
- delay
- max_attempts
- window
9. rollback_config
10. update_config
Others
-
devices
-
depends_on
-
dns
-
dns_search
-
tmpfs
-
entrypoint
-
env_file
-
environment
-
expose
-
external_links
-
extra_hosts
-
healthcheck
-
image
-
init
-
isolation
-
labels
-
links
-
logging
-
network_mode
-
networks
- aliases
- ipv4, ipv6 addresses
-
pid
-
ports
-
secrets
-
security_opt
-
stop_grace_period
-
stop_signal
-
sysctls
sysctls: net.core.somaxconn: 1024 net.ipv4.tcp_syncookies: 0
-
ulimits
-
userns_mode
-
volumes
-
restart
-
domainname, hostname, ipc, mac_address, privileged, read_only, shm_size, stdin_open, tty, user, working_dir
Not supported for docker stack deploy
- build
- cgroup_parent
- container_name
- devices
- tmpfs
- external_links
- links
- network_mode
- restart
- security_opt
- stop_signal
- sysctls
- userns_mode