Docker volumes vs bind mounts is the first storage decision you make when you run WordPress in Docker on a VPS, and it shapes how you back up, update, and move the site later. Pick the wrong one and a server move turns into a hunt for scattered files. Pick the right one and those jobs take minutes.
What Docker Volumes Are
A Docker volume is storage Docker manages for you. You give it a name, Docker creates it inside its own storage area, usually under /var/lib/docker/volumes/, and your container reads and writes through that name.
Volumes exist apart from any single container. Stop the container, remove it, pull a new WordPress image, and start a fresh container with the same volume name, and your uploads, themes, and plugins are still there. Docker creates the volume if it does not exist and sets permissions the container can use. For a WordPress site, a named volume for wp-content and another for the database covers most of what needs to survive a rebuild.
What Bind Mounts Are
A bind mount links a specific folder on your host directly into the container. Mount /srv/wordpress/wp-content at /var/www/html/wp-content, and the container sees exactly the files in that host folder. Edit a file on the host with your normal editor, and the change shows up inside the container at once.
That direct access is the whole appeal. You can browse uploads, search theme files, restore a single file from a backup, or edit wp-config.php without entering the container. The trade-off is that Docker does not manage the folder. You create it, set its permissions, and decide where it lives. Get the path or permissions wrong and WordPress fails in confusing ways, such as uploads that refuse to save or updates that ask for FTP credentials. The comparison in where Docker stores data with volumes vs bind mounts shows where Docker keeps each kind of data.
Docker Volumes vs Bind Mounts: Side-by-Side Comparison
The table below sums up the practical differences for a WordPress site on a VPS.
| Factor | Docker Volume | Bind Mount |
|---|---|---|
| Where files live | Docker-managed area, named by you | A host folder you choose and manage |
| Setup | Created automatically by Compose | You create the folder and set permissions first |
| Editing files directly | Awkward, needs a container command or copy step | Easy, edit on the host with any tool |
| Backups | Back up by volume name, same on any host | Back up the host folder like any directory |
| Moving to a new VPS | Export the volume, import it on the new server | Copy the folder with rsync or a similar tool |
| Permission problems | Rare, Docker sets them up | Common, host and container users often differ |
| Best fit | Live WordPress sites, databases | Theme development, quick file edits, staging copies |
How Each One Behaves With WordPress
WordPress stores different things in different places. Uploads, themes, and plugins live in wp-content, while the database holds posts, settings, and user accounts. Core files can be replaced at any time, so they need less care.
For wp-content, a docker volumes WordPress setup keeps uploads safe across image updates. Run docker compose pull, recreate the container, and the volume stays put. A bind mount does the same job and adds direct access to uploads from the host, which helps when you clean up a bloated media library or restore one image by hand.
For the database, volumes are the safer pick. MySQL or MariaDB expects its data directory to have specific ownership, and a volume gives it that without extra work. A bind mount for database files can work, but a wrong owner on the host folder stops the database from starting, and the error rarely points at permissions first.
For theme development, bind mounts win. Change a template file, refresh the browser, and see the result at once, with no rebuild and no copy step. That fast loop is why many people run a bind mount on a staging copy while the live site runs on volumes. The guide to setting up a staging copy of WordPress on the same VPS shows a setup where that split makes sense.
Backups: Where the Two Options Really Differ
With a volume, you back up by name, so your backup script works the same way on any host. A common pattern is a short-lived container that mounts the volume read-only and writes a compressed archive. For a repeatable routine, how to back up Docker volumes automatically walks through a scheduled approach.
With a bind mount, the files are already in a normal host folder, so any file backup tool can copy them. The catch is that the folder path is part of your setup, so moving to a server with a different layout means updating the script. Either way, test the restore, not just the backup.
Back up the database alongside the files, and keep the two in sync in time, or media entries can point at files that do not exist.
Permissions: The Bind Mount Trap
Most bind mount trouble comes down to user IDs. The WordPress container runs its web server as a particular user, often www-data with user ID 33, while the host folder belongs to your own user or to root. When those do not line up, WordPress cannot write uploads and plugin updates fail.
The fix is to set the host folder owner to match the container user before you start the container, for example by running chown -R 33:33 on the mounted folder. Check ownership with ls -ln rather than guessing. Volumes sidestep this, since Docker creates them with ownership the container can use.
Which One Should You Use for WordPress?
Use Docker volumes for your live WordPress site. They survive container rebuilds, keep the database safe, avoid most permission trouble, and make backup and migration scripts portable across servers. That covers what a live site needs most. On a Linux VPS the speed difference is small, since both use the same disk, so pick based on workflow and backups, not speed.
Use bind mounts when direct file access is the point. Theme and plugin development, a staging copy you edit often, or a site you are still building by hand all benefit from files you can see and touch on the host. A bind mounts WordPress staging copy is a good example. Disk use grows either way as uploads grow, so pair your choice with regular cleanup, as covered in cleaning up old Docker images to free disk space.
You can also mix them. A common pattern is volumes for the database and wp-content/uploads, plus a bind mount for a custom theme folder you are actively working on. The rule is simple: anything the site must not lose goes on a volume, and anything you need to edit by hand goes on a bind mount.
A Practical WordPress Setup With Docker Compose
A typical wordpress docker compose volumes setup names its volumes at the bottom of the Compose file. The WordPress service gets a volume for wp-content, and the database service gets its own volume for its data directory.
services:
wordpress:
image: wordpress:latest
volumes:
- wp-content:/var/www/html/wp-content
db:
image: mariadb:11
volumes:
- db-data:/var/lib/mysql
volumes:
wp-content:
db-data:
To add a bind mount for theme work, map a host folder to the theme directory and keep the rest on volumes. Before switching a live site, copy the data, verify it on a staging copy, and only then change the live Compose file.
Frequently Asked Questions
Can I use volumes and bind mounts together?
Yes. Many WordPress setups use volumes for the database and uploads, and a bind mount for a theme folder under active development. Each service in Compose can mix both types.
What happens to my data if I delete a container?
Nothing, as long as the data lives in a named volume or a bind mount. Deleting a container removes the container only. Data written inside the container itself disappears, which is why the WordPress files that matter should never live only inside the container.
Start with volumes for the live site, add a bind mount only where you need to touch files directly, and back up files and database on a schedule you have actually tested. A docker volume backup routine you have restored at least once is worth more than a perfect choice you never verify.