docker network create wordpress_net
docker \
run \
--name "db" \
-v "$(pwd)/db_data:/var/lib/mysql" \
-e "MYSQL_ROOT_PASSWORD=123456" \
-e "MYSQL_DATABASE=wordpress" \
-e "MYSQL_USER=wordpress_user" \
-e "MYSQL_PASSWORD=123456" \
--network wordpress_net \
mysql:5.7
docker \
run \
--name app \
-v "$(pwd)/app_data:/var/www/html" \
-e "WORDPRESS_DB_HOST=db" \
-e "WORDPRESS_DB_USER=wordpress_user" \
-e "WORDPRESS_DB_NAME=wordpress" \
-e "WORDPRESS_DB_PASSWORD=123456" \
-e "WORDPRESS_DEBUG=1" \
-p 8080:80 \
--network wordpress_net \
wordpress:latest
version: "3.7"
services:
db:
image: mysql:5.7
volumes:
- ./db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress_user
MYSQL_PASSWORD: 123456
app:
depends_on:
- db
image: wordpress:latest
volumes:
- ./app_data:/var/www/html
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress_user
WORDPRESS_DB_PASSWORD: 123456