Local WordPress project running on Docker Compose with a separate MySQL container and simple Makefile commands.
wordpress:latestfor the applicationmysql:8.4for the databasephpmyadmin:latestfor DB web UI.envfor local secrets.env.exampleas an environment variable templateMakefileforup,start,stop,down,restart, andlogs- browser selection via
BROWSER
- Docker
- Docker Compose
make
- [docker-compose.yml](/Users/denis/Documents/Training practice/study repos/wordpress-site/docker-compose.yml:1) defines the
wordpress,db, andphpmyadminservices - [Makefile](/Users/denis/Documents/Training practice/study repos/wordpress-site/Makefile:1) contains helper commands
- [.env.example](/Users/denis/Documents/Training practice/study repos/wordpress-site/.env.example:1) shows the required environment variables
- Create a local
.envfile based on.env.example. - Fill in the values:
MYSQL_ROOT_PASSWORD=change_me_root_password
MYSQL_DATABASE=wordpress
MYSQL_USER=change_me_user
MYSQL_PASSWORD=change_me_password
BROWSER=Firefox Developer Edition.env is not committed to the repository and is used only locally.
Create and start containers, then open the site in the browser configured in BROWSER:
make upAfter startup:
http://localhost:8080
http://localhost:8081
Start already created containers:
make startStop containers without removing them:
make stopStop and remove containers/network:
make downRestart already created containers and open the site again:
make restartView logs:
make logs- the
dbservice starts MySQL - the
wordpressservice connects to the database atdb:3306 - the
phpmyadminservice connects todband is available athttp://localhost:8081 - MySQL data is persisted in the Docker volume
db_data make up,make start, andmake restartwait until thewordpresscontainer becomeshealthy, then runopen -a "$(BROWSER)" http://localhost:8080
3306is the standard internal MySQL port- the database is not exposed to the host machine
BROWSERshould match the macOS application name exactly- if secrets were committed earlier, they should be rotated