Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@cdevroe 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