Feedback

Chat Icon

Painless Docker - 2nd Edition

A Comprehensive Guide to Mastering Docker and its Ecosystem

Docker Volumes & Data Management
40%

Named Volumes vs Anonymous Volumes

When we created the volume my-vol, we used the command:

docker volume create my-vol

This is called a named volume. We can also create anonymous volumes.

Anonymous volumes are volumes that aren't given a specific name. They're created when we use the -v flag without specifying a name:

docker run --name postgres-with-anon-vol \
    -v /var/lib/postgresql/data \
    -e POSTGRES_PASSWORD=mysecretpassword -d \
    postgres:16

If you inspect the container to get the volume name, you will see that it's a random string:

Painless Docker - 2nd Edition

A Comprehensive Guide to Mastering Docker and its Ecosystem

Enroll now to unlock all content and receive all future updates for free.

Unlock now  $31.99$25.59

Hurry! This limited time offer ends in:

To redeem this offer, copy the coupon code below and apply it at checkout:

Learn More