- copy `docker-cmopose.yml` and change base on your setting
version: "3"
services:
db:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.4-focal
# If you really want to use MySQL, uncomment the following line
#image: mysql:8.0.27
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
# - MYSQL_DATABASE=blog # if later on you want to manually create multi database can #this item
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
blog1:
image: wordpress:latest
volumes:
- wp_blog1_data:/var/www/html
ports:
- 8080:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=db_blog1
blog2:
image: wordpress:latest
volumes:
- wp_blog2_data:/var/www/html
ports:
- 8081:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=db_blog2
volumes:
db_data:
wp_blog1_data:
wp_blog2_data:
2. create data base if you want multi dabase in one db instance
docker exec -it ${db container} bash
#use root password to login db
create database db_blog1;
create database db_blog2
grant all on db_blog1.* to 'wordpress'@'%' identified by 'password'
grant all on db_blog2.* to 'wordpress'@'%' identified by 'password'
3. login the url to install your each wordpress instance