Compose will act as a schedule to be executed. What images do I need to prepare, which containers do I need to run. The whole enviroment can be prepared with one .yaml
# docker-compose.yaml
version: [composeVersion]
services: # Containers Definitions
<MY-CONTAINER-1>:
image: <MY-IMAGE:VERSION>
# ... other settings
<MY-CONTAINER-2>:
image: <MY-IMAGE:VERSION>
# ... other settings
...
A version is specified to prevent bugs that might happen when a new version is released. More info about that here.
Define containers and its properties. Example:
version: "3.8"
services:
frontend:
image: mjgargani/compose-example:frontend-trybe1.0
restart: always
ports:
- 3000:3000
depends_on:
- "backend"
backend:
image: mjgargani/compose-example:backend-trybe1.0
restart: always
ports:
- 3001:3001
environment:
- DB_HOST=database
depends_on:
- "database"
database:
build: ./database
restart: always
version: "3.8"
services:
web:
image: nginx:alpine
volumes:
- ./htmlpublic:/usr/share/nginx/html
- # Other Volume
ports:
- 8080:80
The network is created automatically for each service!! It works as a bridge network and is isolated from other containers.
If you want to specify it though:
networks:
- [networkName]