docker compose wordpress plugin code example
Example 1: wordpress docker compose
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
Example 2: wordpress mariadb docker compose
version: '3.6'
services:
wordpress:
image: wordpress:${WORDPRESS_VERSION:-latest}
container_name: ${COMPOSE_PROJECT_NAME:-wordpress}
volumes:
- ./config/php.conf.ini:/usr/local/etc/php/conf.d/php.ini
- ${WORDPRESS_DATA_DIR:-./wordpress}:/var/www/html
environment:
- WORDPRESS_DB_NAME=${COMPOSE_PROJECT_NAME:-wordpress}
- WORDPRESS_TABLE_PREFIX=${WORDPRESS_TABLE_PREFIX:-wp_}
- WORDPRESS_DB_HOST=${WORDPRESS_DB_HOST:-mysql}
- WORDPRESS_DB_USER=${DATABASE_USER:-root}
- WORDPRESS_DB_PASSWORD=${DATABASE_PASSWORD:-password}
depends_on:
- mysql
- phpmyadmin
restart: always
ports:
- 80:80
mysql:
image: mariadb:${MARIADB_VERSION:-latest}
container_name: ${COMPOSE_PROJECT_NAME}_mysql
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=${DATABASE_PASSWORD:-password}
- MYSQL_USER=${DATABASE_USER:-root}
- MYSQL_PASSWORD=${DATABASE_PASSWORD:-password}
- MYSQL_DATABASE=${COMPOSE_PROJECT_NAME:-wordpress}
restart: always
phpmyadmin:
depends_on:
- mysql
image: phpmyadmin/phpmyadmin:${PHPMYADMIN_VERSION:-latest}
container_name: ${COMPOSE_PROJECT_NAME}_phpmyadmin
restart: always
ports:
- ${PHPMYADMIN_PORT}:80
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-password}
# Command line interface to wordpress
wpcli:
build: ./wpcli/
image: wpcli
container_name: ${COMPOSE_PROJECT_NAME}_wpcli
volumes:
- ${WORDPRESS_DATA_DIR:-./wordpress}:/var/www/html
working_dir: /var/www/html
# Check availability of essential services
healthcheck:
image: wpcli
build: ./wpcli/
container_name: ${COMPOSE_PROJECT_NAME}_healthcheck
command: sh -c "/wait"
environment:
- WAIT_HOSTS=mysql:3306, wordpress:80
- WAIT_BEFORE_HOSTS=${WAIT_BEFORE_HOSTS:-30}
- WAIT_AFTER_HOSTS=${WAIT_AFTER_HOSTS:-15}
- WAIT_HOSTS_TIMEOUT=${WAIT_HOSTS_TIMEOUT:-300}
- WAIT_SLEEP_INTERVAL=${WAIT_SLEEP_INTERVAL:-30}
- WAIT_HOST_CONNECT_TIMEOUT=${WAIT_HOST_CONNECT_TIMEOUT:-30}