docker-compose
Mon fichier sql-docker-compose.yml :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
volumes:
mysql_conf:
name: mysql-conf
driver: local
driver_opts:
type: none
o: bind
device: /srv/sql/mysql/conf
mysql_data:
name: mysql-data
driver: local
driver_opts:
type: none
o: bind
device: /srv/sql/mysql/data
postgresql_data:
name: postgresql-data
driver: local
driver_opts:
type: none
o: bind
device: /srv/sql/postgresql/data
networks:
sql_network:
name: sql-network
services:
mysql:
image: mysql:latest
container_name: mysql-container
restart: always
volumes:
- mysql_conf:/etc/mysql/conf.d
- mysql_data:/var/lib/mysql
networks:
- sql_network
environment:
MYSQL_ROOT_PASSWORD: example-password
postgresql:
image: postgres:latest
container_name: postgresql-container
restart: always
volumes:
- postgresql_data:/var/lib/postgresql/data
networks:
- sql_network
environment:
POSTGRES_PASSWORD: example-password
|
Je crée les dossiers utilisés par les containers mysql-container et postgresql-container :
sudo mkdir -p /srv/sql/mysql/conf /srv/sql/mysql/data /srv/sql/postgresql/data
Je crée les containers mysql-container et postgresql-container :
sudo docker-compose -p sql -f ./sql-docker-compose.yml up -d