Menu

1 / 2

Docker Volumes Explained: Keep Your Database Data Safe

DEV Community: docker·Shuvo Halder·13 days ago
#12Xbjh9R
#devtodocker#devto#dev#volume#docker
Long article (2117 words) — no AI summary yet.
Reading 0:00
15s threshold

Your data disappears when your Docker container stops. You restart a database container, the app comes back up, and the data is gone. I learned this the hard way with a test database. The app was fine. The data was not.

The reason is simple, and it is by design. A Docker container is temporary. When you stop it and remove it, the files inside it go away too. That is fine for code. It is bad for a database. Docker volumes fix this. In this post I will show you how Docker volumes work, the difference between named volumes and bind mounts, and the exact commands I use to keep database data safe.

What is a Docker volume?

A Docker volume is storage that lives outside the container. The container can stop, start, or be deleted, and the volume stays. When you start a new container with the same volume, your data is still there.

Think of it this way: the container is the worker, and the volume is the filing cabinet. You can replace the worker.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.