Demystifying Docker Storage Management

Welcome back to another enlightening Docker lecture. In this session, we’re diving deep into the world of Docker storage management, exploring commands related to creating volumes, working with Bind Mounts, and harnessing the power of tmpfs. But before we get hands-on with demos in the next lecture, let’s demystify these essential Docker storage commands.

Creating a Docker Volume

Let’s kick things off by creating Docker volumes. These volumes are essential for persisting and managing data within containers. To create a Docker volume, you can use the docker volume create command, followed by the name of the volume you wish to create. For instance:

docker volume create myvol1

Once your volume is created, you can list all volumes using the docker volume ls command. This will display a list of volumes available on your system:

docker volume ls

If you need more details about a particular volume, you can use the docker volume inspect command, followed by the volume name. This command will provide additional information about the volume, including its driver type, creation date, mount point, and more:

docker volume inspect myvol1

And of course, if you need to remove a volume, you can use the docker volume rm command, followed by the volume name you want to delete:

docker volume rm myvol1

Volume Mounts with Bind Mounts and tmpfs

Now, let’s discuss the different command-line switches and options to mount volumes within your containers. You have several choices, and they offer flexibility to suit your specific needs.

Bind Mounts:

Bind mounts enable you to mount a path from your host machine into a container. You can use either --mount, --volume, or -v to achieve this. Here’s an example using -v:

docker run -v /data/app1:/app-data my_container

In this example, /data/app1 on your host machine is mounted into the /app-data directory within the container.

If you prefer to use --mount, the syntax would be:

docker run --mount type=bind,source=/data/app1,target=/app-data my_container

You can also use aliases like src and destination instead of source and target to make the command more concise.


Docker allows you to create a tmpfs mount inside a container, which is a temporary file system located in RAM. This is perfect for non-persistent data that requires high-speed access. To create a tmpfs mount, you can use the --mount option:

docker run --mount type=tmpfs,destination=/app-data-tmp my_container

Alternatively, you can use --tmpfs instead of --mount to achieve the same result:

docker run --tmpfs /app-data-tmp my_container

These tmpfs mounts provide blazing-fast performance since data writes occur in memory, with no disk-related delays.

These versatile options for mounting volumes and tmpfs mounts give you the power to manage your Docker container’s storage effectively.

In Conclusion

You’re now armed with essential Docker storage commands, enabling you to create volumes, work with Bind Mounts, and leverage tmpfs for high-speed, non-persistent data. In the next lecture, we’ll put theory into practice with hands-on demos, showcasing the power of these commands. Stay tuned for more Docker mastery!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top