Home > Article > Operation and Maintenance > What is a YML file in Docker?
#What is a YML file in Docker?
The YML file in Docker generally refers to the Docker default template file "docker-compose.yml". Each service used to define this file must specify the image through the image command, or use the Dockerfile The build command performs automatic building.
Compose file
The Compose file is a YAML file that defines services, networks, and volumes. The default path is. /docker-compose.yml, you can use .yml or .yaml as the file extension.
Service services definition contains configuration that applies to each container started for that service, similar to passing command line parameters to docker container create. Likewise, networks and volumes are defined similarly to docker network create and docker volume create. Just as docker container create specifies options in the Dockerfile, such as CMD, EXPOSE, VOLUME, and ENV, by default, there is no need to specify them again in the docker-compose.yml configuration. Environment variables can be used in configuration values using the Bash class ${VARIABLE} syntax.
version: "3" services: redis: image: redis:alpine ports: - "6379" networks: - frontend deploy: replicas: 2 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure db: image: postgres:9.4 volumes: - db-data:/var/lib/postgresql/data networks: - backend deploy: placement: constraints: [node.role == manager] vote: image: dockersamples/examplevotingapp_vote:before ports: - 5000:80 networks: - frontend depends_on: - redis deploy: replicas: 2 update_config: parallelism: 2 restart_policy: condition: on-failure result: image: dockersamples/examplevotingapp_result:before ports: - 5001:80 networks: - backend depends_on: - db deploy: replicas: 1 update_config: parallelism: 2 delay: 10s restart_policy: condition: on-failure worker: image: dockersamples/examplevotingapp_worker networks: - frontend - backend deploy: mode: replicated replicas: 1 labels: [APP=VOTING] restart_policy: condition: on-failure delay: 10s max_attempts: 3 window: 120s placement: constraints: [node.role == manager] visualizer: image: dockersamples/visualizer:stable ports: - "8080:8080" stop_grace_period: 1m30s volumes: - "/var/run/docker.sock:/var/run/docker.sock" deploy: placement: constraints: [node.role == manager] networks: frontend: backend: volumes: db-data:
Recommended tutorial: "Docker"
The above is the detailed content of What is a YML file in Docker?. For more information, please follow other related articles on the PHP Chinese website!