DELAPARRA
Index
Color
NL
Category: Docker

VOLUME

Explained by Updated

What is VOLUME?

VOLUME: Declares a mount point whose data should live in a volume, outside the container's writable layer. VOLUME in a Dockerfile marks a folder whose data should live outside the container's own file system, such as VOLUME ["/var/lib/mysql"]. When a container starts, Docker mounts a volume there. If you do not provide a named volume yourself, Docker creates an anonymous one with a random name. That is how data can seem to disappear: a new container gets a new anonymous volume, while the old data sits in another one.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about VOLUME

What should you keep in mind with VOLUME?

Many official database images declare volumes for their data folders. In your own images, use VOLUME sparingly, because later Dockerfile steps cannot change files in a declared volume. Prefer declaring volumes at runtime, in docker run -v or the Compose file, with clear names, so it is obvious where data lives and how to back it up.

What does an example of VOLUME look like?

VOLUME ["/var/lib/data"]

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with V

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.