1version: 'X.X'
2 services:
3 db:
4 image: mysql
5 restart: always
6 environment:
7 MYSQL_DATABASE: 'db' # So you don't have to use root, but you can if you like
8 MYSQL_USER: 'user' # You can use whatever password you like
9 MYSQL_PASSWORD: 'password' # Password for root access
10 MYSQL_ROOT_PASSWORD: 'password'
11 ports: # <Port exposed> : < MySQL Port running inside container>
12 - '3306:3306'
13 expose: # Opens port 3306 on the container
14 - '3306' # Where our data will be persisted
15 volumes:
16 - my-db:/var/lib/mysql # Names our volume
17 volumes:
18 y-db:
1version: '3.3'
2
3services:
4 db:
5 image: mysql:5.7
6 volumes:
7 - db_data:/var/lib/mysql
8 restart: always
9 environment:
10 MYSQL_ROOT_PASSWORD: somewordpress
11 MYSQL_DATABASE: wordpress
12 MYSQL_USER: wordpress
13 MYSQL_PASSWORD: wordpress
14
15 wordpress:
16 depends_on:
17 - db
18 image: wordpress:latest
19 ports:
20 - "8000:80"
21 restart: always
22 environment:
23 WORDPRESS_DB_HOST: db:3306
24 WORDPRESS_DB_USER: wordpress
25 WORDPRESS_DB_PASSWORD: wordpress
26 WORDPRESS_DB_NAME: wordpress
27volumes:
28 db_data: {}
29