By Sheldon L | Published at 2020-03-01 | Updated at 2020-03-01 |
Find Wordpress
, mysql
, phpmyadmin
in dockerhub, notice the environment va;
Create a single file to set all of this up:
docker-compose.yml
version: '3'
services:
# database
db:
container_name: mysql
image: mysql:5.7
restart: always
networks:
- wpsite
volumes:
- ./db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 4869
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: 4869
# service
phpmyadmin:
depends_on:
- db
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin
restart: always
networks:
- wpsite
ports:
- 8080:80
environment:
PMA_HOST: db:3306
MYSQL_ROOT_PASSWORD: 4869
# wordpress
wordpress:
depends_on:
- db
container_name: wordpress
image: wordpress:latest
restart: always
networks:
- wpsite
ports:
- 8000:80
volumes:
- ./wordpress:/var/www/html
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: 4869
volumes:
db_data:
wordpress:
networks:
wpsite:
sudo docker-compose up # create and build
sudo docker-compose down # remove
sudo docker-compose start
sudo docker-compose stop
sudo docker-compose push
sudo docker-compose pull
sudo docker-compose help
# ...
Push to github: my_first_WordPress
Pull to VPS
More: wordpress with nginx