Skip to content

Instantly share code, notes, and snippets.

@erikyuzwa
Last active February 23, 2025 18:03
Show Gist options
  • Save erikyuzwa/7411752ddcb95b09434aa88f38d91630 to your computer and use it in GitHub Desktop.
Save erikyuzwa/7411752ddcb95b09434aa88f38d91630 to your computer and use it in GitHub Desktop.
Wordpress 6.2.2 Docker Compose for Local Development
# create a local .env file with the following 4 properties:
#
# MYSQL_DATABASE=<something>
# MYSQL_USER=<something>
# MYSQL_PASSWORD=<something>
# MYSQL_ROOT_PASSWORD=<something>
#
# Note: I have had a LOT of issues working with anything newer then Docker Desktop v4.26.1
# If you're on something newer, then double check against this release.
#
# I also have a video going through this here: https://www.youtube.com/watch?v=gEceSAJI_3s
version: "3.8"
services:
database:
# We use a mariadb image which supports both amd64 & arm64 architecture
image: mariadb:10.6.4-focal
restart: unless-stopped
ports:
- 3306:3306
env_file: .env
environment:
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
MYSQL_DATABASE: '${MYSQL_DATABASE}'
MYSQL_USER: '${MYSQL_USER}'
MYSQL_PASSWORD: '${MYSQL_PASSWORD}'
volumes:
- db-data:/var/lib/mysql
networks:
- wordpress-network
deploy:
resources:
limits:
memory: 2048m
phpmyadmin:
depends_on:
- database
image: phpmyadmin/phpmyadmin
restart: unless-stopped
ports:
- 8081:80
env_file: .env
environment:
PMA_HOST: database
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
networks:
- wordpress-network
wordpress:
depends_on:
- database
image: wordpress:6.2.2-apache
restart: unless-stopped
ports:
- 8080:80
env_file: .env
environment:
WORDPRESS_DB_HOST: database:3306 # use the same name as database service
WORDPRESS_DB_NAME: '${MYSQL_DATABASE}'
WORDPRESS_DB_USER: '${MYSQL_USER}'
WORDPRESS_DB_PASSWORD: '${MYSQL_PASSWORD}'
volumes:
- ./wp-content:/var/www/html/wp-content
networks:
- wordpress-network
volumes:
db-data:
networks:
wordpress-network:
driver: bridge
@stakhursky
Copy link

Thank you for sharing!

@jhernandez18p
Copy link

Thanks so much. It was just what I was looking for. Just starting with docker.

@milotig
Copy link

milotig commented Nov 26, 2024

Thx. :)

@jcdacula7
Copy link

jcdacula7 commented Dec 6, 2024

May I ask what is the content of the .dockerignore file? It's in the video but wasn't discuss. Thank you!

image

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