Skip to content

Instantly share code, notes, and snippets.

@truongluu
Forked from drdogbot7/docker-compose.yml
Created May 15, 2024 15:27
Show Gist options
  • Save truongluu/c273cbf1c3e8ec22849a1b7f2cd167e2 to your computer and use it in GitHub Desktop.
Save truongluu/c273cbf1c3e8ec22849a1b7f2cd167e2 to your computer and use it in GitHub Desktop.
Wordpress Docker Compose with CLI - official images
version: '2'
services:
db:
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
ports:
- "[YOUR_DESIRED_SQL_PORT]:3306"
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wp:
depends_on:
- db
image: wordpress
links:
- db
ports:
- "[YOUR_DESIRED_HTTP_PORT]:80"
working_dir: /var/www/html
volumes:
- ./wp-content/:/var/www/html/wp-content
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_TABLE_PREFIX: "wp_"
wpcli:
image: wordpress:cli
volumes_from:
- wp
links:
- db
entrypoint: wp
command: "--info"

Running WP-CLI commands

docker-compose run --rm wpcli [YOUR WPCLI COMMAND]

EXAMPLE: docker-compose run --rm wpcli media regenerate --only-missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment