Difference between revisions of "Docker compose file: docker-compose.yml"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(31 intermediate revisions by 4 users not shown)
Line 9: Line 9:
 
== YAML Explained ==
 
== YAML Explained ==
 
Version and at least one service is needed.
 
Version and at least one service is needed.
 
+
  [[services:]]
version: "3.7"
 
  services:
 
 
   ...
 
   ...
  [[docker-compose: volumes|volumes]]: <ref>https://docs.docker.com/compose/compose-file/#volumes</ref>
+
  [[docker-compose: volumes|volumes:]] <ref>https://docs.docker.com/compose/compose-file/#volumes</ref>
 
   ...
 
   ...
  networks:
+
  [[config:]] <ref>https://docs.docker.com/compose/compose-file/#configs</ref>
 +
...
 +
[[secrets: (docker-compose.yml)|secrets:]]<ref>https://docs.docker.com/compose/compose-file/#secrets</ref>
 +
...
 +
[[docker-compose: networks|networks]]: <ref>https://docs.docker.com/compose/compose-file/#network-configuration-reference</ref>
 
   ...
 
   ...
 +
 +
 +
 +
  version: "3.9" Informative/deprecated https://docs.docker.com/compose/compose-file/#version-top-level-element
  
 
== Version 3 ==
 
== Version 3 ==
 +
https://docs.docker.com/compose/compose-file/compose-versioning/#versioning
 +
  
 
* [[Version 3 resource limitation]]
 
* [[Version 3 resource limitation]]
  
 
Removed options: <code>volume_driver, volumes_from, cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, extends, group_add</code>
 
Removed options: <code>volume_driver, volumes_from, cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, extends, group_add</code>
 +
 +
 +
v3.8
 +
* <code>max_replicas_per_node</code> in placement configurations
 +
 +
  
 
v3.7 (18.06.0+) (2018-07-17)<ref>https://github.com/docker/compose/blob/master/CHANGELOG.md#1220-2018-07-17</ref>
 
v3.7 (18.06.0+) (2018-07-17)<ref>https://github.com/docker/compose/blob/master/CHANGELOG.md#1220-2018-07-17</ref>
Line 35: Line 49:
 
* <code>isolation</code> in service definitions
 
* <code>isolation</code> in service definitions
 
* <code>name</code> for networks, secrets and configs
 
* <code>name</code> for networks, secrets and configs
* <code>shm_size</code> in build configurations
+
* <code>[[shm_size]]</code> in [[build:|build]] configurations
  
 
v3.2
 
v3.2
Line 47: Line 61:
 
== Restart policy ==
 
== Restart policy ==
 
* Version 3: <code>https://docs.docker.com/compose/compose-file/#restart_policy</code>
 
* Version 3: <code>https://docs.docker.com/compose/compose-file/#restart_policy</code>
  restart: "no"        (default)
+
  [[restart:]] "no"        (default)
 
  restart: always
 
  restart: always
 
  restart: on-failure
 
  restart: on-failure
Line 71: Line 85:
 
See also: [[docker logs]]: <code>docker logs --since 1h CONTAINER_NAME</code>
 
See also: [[docker logs]]: <code>docker logs --since 1h CONTAINER_NAME</code>
  
 +
 +
== Related terms ==
 +
* <code>[[depends_on]]</code>
 +
* <code>container_name</code> https://docs.docker.com/compose/compose-file/#container_name
 +
* <code>mem_limit</code>
 +
* <code>domainname, [[hostname]], ipc, mac_address, privileged, read_only, shm_size, stdin_open, tty, user, working_dir</code><ref>https://docs.docker.com/compose/compose-file/compose-file-v3/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir</ref>
 +
* <code>[[docker-compose up]]</code>
 +
* <code>[[expose:]], [[ports:]]</code>
 +
* <code>[[labels:]]</code>
 +
* <code>[[build:]]</code>
 +
* [[docker-compose.yml: image:]]
 +
* <code>[[yq]] '.services[].container_name' docker-compose.yml</code>
  
 
== See also ==
 
== See also ==
* [[Dockerfile]]
+
* <code>[[Dockerfile]]</code>
 
* [[Version 3 resouces]]
 
* [[Version 3 resouces]]
 +
* {{docker-compose.yml}}
 
* {{docker-compose}}
 
* {{docker-compose}}
  

Latest revision as of 14:52, 25 August 2024

Review different versions of docker-compose.yml

[1]

docker-compose.yml examples[edit]

YAML Explained[edit]

Version and at least one service is needed.

services:
 ...
volumes: [2]
 ...
config: [3]
...
secrets:[4]
...
networks: [5]
 ...


 version: "3.9" Informative/deprecated https://docs.docker.com/compose/compose-file/#version-top-level-element

Version 3[edit]

https://docs.docker.com/compose/compose-file/compose-versioning/#versioning


Removed options: volume_driver, volumes_from, cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, extends, group_add


v3.8

  • max_replicas_per_node in placement configurations


v3.7 (18.06.0+) (2018-07-17)[6]

  • init in service definitions
  • rollback_config in deploy configurations
  • Support for extension fields at the root of service, network, volume, secret and config definitions

v3.6 (8.02.0+)

  • tmpfs size for tmpfs-type mounts

v3.5

  • isolation in service definitions
  • name for networks, secrets and configs
  • shm_size in build configurations

v3.2

  • CACHE_FROM added


v3.1 (2017-02-08)[7]

Restart policy[edit]

restart: "no"         (default)
restart: always
restart: on-failure
restart: unless-stopped
restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
  • Version 2:
- restart: no|always|on-failure</code><ref>https://docs.docker.com/compose/compose-file/compose-file-v2/</ref>

logging[edit]

driver: none|local|json-file|syslog|journald|gelf|fluentd|awslogs|splunk|etwlogs|gcplogs|logentries
json-file is the default option

See also: docker logs: docker logs --since 1h CONTAINER_NAME


Related terms[edit]

See also[edit]


Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.

Original Source: https://en.wikiversity.org/wiki/DevOps/Docker/docker_compose/Docker_compose_file:_docker-compose.yml

Advertising: