docker-compose.yml⚓︎
Overview⚓︎
The docker-compose.yml
file is used to define and run multi-container Docker applications. It specifies the services, networks, and volumes for a project, as well as the configuration of each service. In this specific file, it is used to define two database services, MySQL and PostgreSQL, for a project.
Table of Contents⚓︎
Prerequisites⚓︎
- Docker installed on the host machine
- Docker Compose version 2.2
Usage⚓︎
To use this docker-compose.yml
file in a project, follow these steps: 1. Make sure Docker and Docker Compose are installed on the host machine. 2. Create a new directory for your project and place the docker-compose.yml
file in it. 3. Open a terminal and navigate to the project directory. 4. Run the following command to start the defined services:
Methods⚓︎
This file does not contain any methods or functions, as it is used to define the configuration of Docker services for a project.
Useful details⚓︎
- Docker Compose version: "2.2"
- Services defined:
- MySQL:
- Image: mysql:8.2
- Ports: 3306
- Environment variables:
- MYSQL_ROOT_PASSWORD
- MYSQL_ALLOW_EMPTY_PASSWORD
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_DATABASE
- Volumes: ./conf.d:/etc/mysql/conf.d
- Profiles: mysql
- PostgreSQL:
- Image: postgres:16.1
- Ports: 5432
- Environment variables:
- POSTGRES_PASSWORD
- POSTGRES_USER
- POSTGRES_DB
- Profiles: postgres