Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of docker compose file with WP and WP-CLI (allowed root). Note to self: when specifying command parameter in the compose file you'll need to add the default entrypoint and commands that are running on the default image you're pulling info from.
version: "3.9"
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
volumes:
- ./:/var/www/html
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WP_CLI_ALLOW_ROOT: "true"
command: >
bash -c "curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar;
chmod +x wp-cli.phar;
mv wp-cli.phar /usr/local/bin/wp;
sh /usr/local/bin/docker-entrypoint.sh;
apache2-foreground;"
volumes:
db_data: {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment