Skip to content

Instantly share code, notes, and snippets.

@cdevroe
Created March 4, 2021 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdevroe/6d7d4bd01827627215787e9712ab903b to your computer and use it in GitHub Desktop.
Save cdevroe/6d7d4bd01827627215787e9712ab903b to your computer and use it in GitHub Desktop.
Docker Compose for WordPress with theme mapped (example for my blog)
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
volumes:
- /Users/cdevroe/Sites/wordpress_themes/cypress/dist:/var/www/html/wp-content/themes/cypress
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: {}
@cdevroe
Copy link
Author

cdevroe commented Mar 4, 2021

For those that want to map a local directory to one within the Docker container, look at the bit around Line 20.

volumes:
       - /Users/cdevroe/Sites/wordpress_themes/cypress/dist:/var/www/html/wp-content/themes/cypress

This maps my local directory to one within WordPress in the container. Every time I save my theme files they are immediately live within WordPress.

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