Docker Desktop volumes for WordPress
Summary
1. Create Local Folders for Data
Choose a location on your computer where Docker will store persistent WordPress and MySQL data.
Windows
mkdir C:\docker-data\wp_html
mkdir C:\docker-data\mysql
Output
- C:\docker-data\wp_html for WordPress files
- C:\docker-data\mysql for MySQL database files
macOS / Linux
mkdir -p ~/docker-data/wp_html
mkdir -p ~/docker-data/mysql
Output
- ~/docker-data/wp_html for WordPress files
- ~/docker-data/mysql for MySQL database files
2. Create Bind-Backed Docker Volumes
Create named Docker volumes that bind to the local folders you created earlier. This allows Docker to store WordPress and database data in those folders instead of inside Docker’s default internal storage.
Windows
docker volume create wp_html --driver local --opt type=none --opt device=C:\docker-data\wp_html --opt o=bind
docker volume create mysql_data --driver local --opt type=none --opt device=C:\docker-data\mysql --opt o=bind
macOS / Linux
docker volume create wp_html --driver local --opt type=none --opt device=$HOME/docker-data/wp_html --opt o=bind
docker volume create mysql_data --driver local --opt type=none --opt device=$HOME/docker-data/mysql_data --opt o=bind
Options explained
docker volumecreates a new Docker volume. In this example, wp_html and mysql_data are the names of the volumes being created.--driverlocal tells Docker to use the local volume driver.--opt type=noneis used when creating a bind-backed volume.--opt device=...tells Docker which folder on your machine should be used for the volume.--opt o=bindtells Docker to bind that folder into the volume.
3. Verify the Docker Volumes
Check that Docker is using the local folders you mapped.
docker volume inspect wp_html
Output
Docker will return JSON describing the volume configuration.
[
{
"CreatedAt": "2026-03-17T12:01:21Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/wp_html/_data",
"Name": "wp_html",
"Options": {
"device": "C:\\docker-data\\wp_html",
"o": "bind",
"type": "none"
},
"Scope": "local"
}
]
docker volume inspect mysql_data
Output
[
{
"CreatedAt": "2026-03-17T12:00:51Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/mysql_data/_data",
"Name": "mysql_data",
"Options": {
"device": "C:\\docker-data\\mysql",
"o": "bind",
"type": "none"
},
"Scope": "local"
}
]
4. Start Your Containers Using the Volumes
After the volumes have been created, they can be attached to your WordPress and database containers. When the containers use wp_html and mysql_data, Docker stores the data in the local folders you configured earlier rather than in Docker’s default internal storage.
A typical setup maps
wp_html -> /var/www/html
mysql_data -> /var/lib/mysql
You can then start your containers with Docker Compose, depending on how your project is structured. Because the data is stored outside the containers, it remains available even if the containers are stopped, removed, or recreated.
This gives you a straightforward Docker Desktop development setup with persistent storage. WordPress files remain available between container restarts, MySQL data is retained even if containers are rebuilt, and the files stay accessible from the host machine. Another advantage is that no manual disk formatting or mounting is required.
Because this approach works across Windows, macOS, and Linux with Docker Desktop, it is well suited to local WordPress development, plugin testing, theme experimentation, or preparing an application before deploying it to a cloud server.

Leave a Reply
You must be logged in to post a comment.