This is a super simple and basic way to get WordPress running locally with docker-compose. More details on how this works can be found on the official WordPress image page.
This should run on PC/MAC/Raspberry Pi
Copy/Paste into a new file names: docker-compose.yaml
services:
db:
image: mariadb:10.6.4-focal
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
db_data:
Once this is completed, run the following in the same directory/folder you created docker-compose.yaml
$ docker-compose up -d
After a little bit, WordPress will be running in the background. You can access using http://localhost

In order to stop and remove the container, run the following:
docker-compose down
To get rid of all of it, pass the -v parameter:
$ docker-compose down -v