This shows you the differences between two versions of the page.
ii:labs:s2:05 [2024/04/29 18:36] radu.ciobanu |
ii:labs:s2:05 [2025/04/13 18:19] (current) florin.stancu |
||
---|---|---|---|
Line 1: | Line 1: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
- | ====== Lab 05 - Docker Compose ====== | + | ====== Lab 06 - Docker Compose ====== |
===== Objectives ===== | ===== Objectives ===== | ||
Line 21: | Line 21: | ||
[[https://docs.docker.com/compose/|Docker Compose]] is a utility created by Docker that is used to centralise the configuration process of a container-based application in a declarative manner, using Yet Another Markup Language (YAML) configuration files. | [[https://docs.docker.com/compose/|Docker Compose]] is a utility created by Docker that is used to centralise the configuration process of a container-based application in a declarative manner, using Yet Another Markup Language (YAML) configuration files. | ||
- | Moreover, the format for Compose files is also used in **//Docker Swarm//**, the orchestrator created by Docker for managing Docker services, which we will discuss in [[ii:labs:s2:05|lab 5]]. | + | Moreover, the format for Compose files is also used in **//Docker Swarm//**, the orchestrator created by Docker for managing Docker services. |
<note tip>You will notice that in this lab we use the terms //**service**// and //**container**// interchangeably. This is because Docker Swarm works with services, while Docker Compose works with containers. We refer to both terms in the same context because the configuration is 90% identical, regardless of whether Swarm or Compose is used. </note> | <note tip>You will notice that in this lab we use the terms //**service**// and //**container**// interchangeably. This is because Docker Swarm works with services, while Docker Compose works with containers. We refer to both terms in the same context because the configuration is 90% identical, regardless of whether Swarm or Compose is used. </note> | ||
Line 43: | Line 43: | ||
<code yaml> | <code yaml> | ||
# docker-compose.yml | # docker-compose.yml | ||
- | version: "3.8" | + | #version: "3.8" |
services: | services: | ||
Line 54: | Line 54: | ||
- "5000:80" | - "5000:80" | ||
networks: | networks: | ||
- | - lab4-network | + | - lab5-network |
postgres: | postgres: | ||
image: postgres:12 | image: postgres:12 | ||
volumes: | volumes: | ||
- | - lab4-volume:/var/lib/postgresql/data | + | - lab5-volume:/var/lib/postgresql/data |
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql | - ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql | ||
networks: | networks: | ||
- | - lab4-network | + | - lab5-network |
volumes: | volumes: | ||
- | lab4-volume: | + | lab5-volume: |
networks: | networks: | ||
- | lab4-network: | + | lab5-network: |
</code> | </code> | ||
Line 75: | Line 75: | ||
The //**version**// attribute describes what [[https://docs.docker.com/compose/compose-file/|functionalities]] will be loaded when running the Docker Compose utility. | The //**version**// attribute describes what [[https://docs.docker.com/compose/compose-file/|functionalities]] will be loaded when running the Docker Compose utility. | ||
- | <note warning>You must specify the version in any Docker Compose file.</note> | + | <note warning>The ''version'' field has been deprecated on modern docker compose versions.</note> |
=== Services === | === Services === |