--- description: Find a quick reference for Docker Compose version 3, including Docker Engine compatibility, memory limitations, and more. keywords: docker compose ports, docker compose version 3, docker-compose memory limit version 3, docker compose 3 memory limit title: Compose file version 3 reference toc_max: 4 toc_min: 1 sitemap: false --- {{< include "compose-eol.md" >}} ## Reference and guidelines These topics describe version 3 of the Compose file format. ## Compose and Docker compatibility matrix There are several versions of the Compose file format – 1, 2, 2.x, and 3.x. The table below is a quick look. For full details on what each version includes and how to upgrade, see **[About versions and upgrading](compose-versioning.md)**. {{< include "content/compose-matrix.md" >}} ## Compose file structure and examples Here is a sample Compose file from the voting app sample used in the [Docker for Beginners lab](https://github.com/docker/labs/tree/master/beginner/) topic on [Deploying an app to a Swarm](https://github.com/docker/labs/blob/master/beginner/chapters/votingapp.md): {{< accordion title="Example Compose file version 3" >}} ```yml version: "{{% param "compose_file_v3" %}}" 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: max_replicas_per_node: 1 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: ``` {{< /accordion >}} The topics on this reference page are organized alphabetically by top-level key to reflect the structure of the Compose file itself. Top-level keys that define a section in the configuration file such as `build`, `deploy`, `depends_on`, `networks`, and so on, are listed with the options that support them as sub-topics. This maps to the `: