docker-compose-yml
- Compose YAML format has it's own versions:
| Compose file format | Docker Engine release |
|---|---|
| 3.7 | 18.06.0+ |
| 3.6 | 18.02.0+ |
| 3.5 | 17.12.0+ |
| 3.4 | 17.09.0+ |
| 3.3 | 17.06.0+ |
| 3.2 | 17.04.0+ |
| 3.1 | 1.13.1+ |
| 3.0 | 1.13.0+ |
| 2.3 | 17.06.0+ |
| 2.2 | 1.13.0+ |
| 2.1 | 1.12.0+ |
| 2.0 | 1.10.0+ |
| 1.0 | 1.9.1.+ |
- YAML file can be used with
docker-composecommand for local docker automation or.. - With
dockerdirectly in production with Swarm (as of v1.13) docker-compose --helpdocker-compose.ymlis default filename, but any can be used withdocker-compose -f
Template
version: '3.1' # if no version is specificed then v1 is assumed. Recommend v2 minimum
services: # containers. same as docker run
servicename: # a friendly name. this is also DNS name inside network
image: # Optional if you use build:
command: # Optional, replace the default CMD specified by the image
environment: # Optional, same as -e in docker run
volumes: # Optional, same as -v in docker run
servicename2:
volumes: # Optional, same as docker volume create
networks: # Optional, same as docker network create
Using Compose to Build
- Compose can also build your custom images
- Will build them with
docker-compose upif not found in cache - Also rebuild with
docker-compose build Great for complex builds that have lots of vars or build args