This file will setup Wordpress, wordpress-cli & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yml" and run the command
#To Start
$ docker-compose up -d
# To Stop
$ docker-compose down --volumes
#wp-cli example
$ docker-compose run --rm wpcli wp db optimize
http://localhost:9080/ #phpMyAdmin
http://localhost:8080/ #Wordpress
version: '3.1'
services:
#Wordpress
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
#Wordpress ENV Variables
WORDPRESS_DB_HOST: db #Name of DB image
WORDPRESS_DB_USER: mydbusername #DB username defined on DB image
WORDPRESS_DB_PASSWORD: root #DB password defined on DB image
WORDPRESS_DB_NAME: mydbname #DB name defined on DB image
WORDPRESS_TABLE_PREFIX: wp_ #table prefix
volumes:
- ./:/var/www/html
networks:
- wpsite
#Database
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: mydbname
MYSQL_USER: mydbusername
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
volumes:
- db:/var/lib/mysql
networks:
- wpsite
#WP CLI
wpcli:
image: wordpress:cli
working_dir: /var/www/html
environment:
WORDPRESS_DB_HOST: db #Name of DB image
WORDPRESS_DB_USER: mydbusername #DB username defined on DB image
WORDPRESS_DB_PASSWORD: root #DB password defined on DB image
WORDPRESS_DB_NAME: mydbname #DB name defined on DB image
WORDPRESS_TABLE_PREFIX: wp_ #table prefix
volumes:
- ./:/var/www/html
depends_on:
- db
- wordpress
networks:
- wpsite
#phpMyAdmin
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 9080:80
depends_on:
- db
environment:
#PMA_ARBITRARY = 1
MYSQL_ROOT_PASSWORD: root
PMA_HOST: db
networks:
- wpsite
volumes:
wordpress:
db:
networks:
wpsite: