DEV Community

Raunak Jain
Raunak Jain

Posted on

How to locate data volumes in Docker Desktop?

Docker Desktop makes it simple to run Docker on your computer. One common task is to find where your data volumes are stored. Data volumes help keep your files safe even if a container is removed. In this guide, we will learn how to locate these data volumes in Docker Desktop. I use simple words and short sentences so it is easy to follow.


Introduction

Docker volumes store your data outside of the container. They let you keep information safe between container restarts. When you work with Docker Desktop, you may wonder where these volumes live. Unlike files on your normal computer, volumes are hidden inside Docker’s internal storage. This article shows you several ways to find them.

Understanding how Docker volumes work is very helpful. You can read more about this in our article on what are docker volumes and how do they work? This gives you a good background.


Docker Desktop and Its Storage

Docker Desktop runs Docker in a special virtual machine. On Windows and macOS, this virtual machine hides many file system details. Data volumes are kept inside this VM and are not directly visible in your normal file explorer.

Because of this, the easiest way to locate volumes is by using Docker commands. The Docker CLI lets you list, inspect, and manage volumes. If you want a more complete guide on creating and using volumes, see how to create and use docker volumes.


Listing Your Data Volumes

The first step is to list all your volumes using the Docker CLI. Open a terminal and run:

docker volume ls
Enter fullscreen mode Exit fullscreen mode

This command prints a list of volumes with their names. Each volume has a unique name, which you can use later to inspect it in more detail.

For example, you might see output like this:

DRIVER    VOLUME NAME
local     pgdata
local     myapp_volume
Enter fullscreen mode Exit fullscreen mode

This shows that there are volumes named pgdata and myapp_volume. To learn more about each volume, you can inspect them.


Inspecting a Specific Volume

Once you have a volume name, use the following command to get details:

docker volume inspect <volume_name>
Enter fullscreen mode Exit fullscreen mode

Replace <volume_name> with the name from your list. For example:

docker volume inspect pgdata
Enter fullscreen mode Exit fullscreen mode

This command returns a JSON object with information about the volume. It shows the driver, the mount point inside the Docker VM, and other details.

By reading the output, you can see the location where Docker Desktop stores the volume data. The mount point is a path on the VM's internal file system. Although you cannot easily browse this path from your host machine, you now know where the data lives inside Docker.

For more on listing and inspecting volumes, check out our guide on how to list and inspect docker volumes.


Accessing Volume Data

In many cases, you do not need to access the data files directly. Instead, you can use containers to work with your data. However, if you need to open a shell inside a container and check the files, you can run a temporary container that mounts the volume.

For example, to open a shell and explore a volume named myapp_volume, run:

docker run --rm -it -v myapp_volume:/data alpine sh
Enter fullscreen mode Exit fullscreen mode

This command does the following:

  • --rm removes the container when you exit.
  • -it opens an interactive terminal.
  • -v myapp_volume:/data mounts the volume to the container’s /data folder.
  • alpine sh starts a simple Alpine Linux shell.

Once inside, you can list files in the /data folder to see your volume’s contents. When you are done, type exit to leave the shell.

For advanced users who wish to mount directories from the host to containers, you may also find the article on how to mount host directories to docker containers useful. It explains the difference between volumes and bind mounts.


Using Docker Desktop UI

Docker Desktop also provides a graphical user interface (GUI) to manage containers and images. While the GUI does not show volume file paths directly, it can help you see which volumes are in use.

  1. Open Docker Desktop.
  2. Go to the Volumes tab in the Dashboard.
  3. Here, you can see a list of volumes. Click on one to view its details.

This method is useful if you prefer to use a point-and-click approach rather than the command line. It also gives you a quick overview of all storage used by Docker.

If you are not sure how to use Docker Desktop, check out our article on what is Docker Desktop and how do you use it? for a basic introduction.


Where Are Volumes Stored on Your Host?

Because Docker Desktop runs inside a VM, the actual files are stored in a hidden area. On macOS, the files are usually in a virtual disk image managed by Docker. On Windows, they are inside a Hyper-V or WSL 2 distribution.

For most users, it is best not to change these settings manually. Instead, work with volumes using Docker commands or the Docker Desktop UI. The system handles the details for you. Knowing that the data is safe inside the VM is usually enough.


Why Locating Volumes Matters

There are several reasons why you might need to locate your Docker volumes:

  • Troubleshooting: If you have problems with a container, inspecting the volume can help diagnose the issue.
  • Backups: You may want to back up important data stored in a volume.
  • Data Migration: When moving data from one system to another, knowing the volume details is helpful.

Understanding where your data lives and how it is managed is a key part of using Docker well. For more insight into docker volumes, you might also review our guide on what are docker volumes and how do they work?


Best Practices

Here are some best practices for working with Docker volumes in Docker Desktop:

  • Use Named Volumes:

    Always use named volumes instead of anonymous ones. This makes it easier to track and manage your data.

  • Regularly Inspect Volumes:

    Use docker volume ls and docker volume inspect to monitor your volumes. This helps you understand their size and usage.

  • Backup Important Data:

    Create regular backups of critical volumes. Even if the files are hidden inside the VM, you can export the data using a temporary container.

  • Use the Docker Desktop UI:

    The Dashboard gives a quick view of your volumes. It is a helpful tool for new users who are not comfortable with the CLI.

For more details on how to work with volumes and keep your data safe, you may refer to our article on how to create and use docker volumes.


Conclusion

Locating data volumes in Docker Desktop is a key skill for anyone working with Docker. By using simple commands like docker volume ls and docker volume inspect, you can easily list and find your volumes. The Docker Desktop UI also offers a simple way to view volume information. Although the actual files are stored inside a hidden VM, you can work with them safely using Docker commands.

To learn more about Docker storage, check out our guides on:

By following these simple steps and best practices, you can confidently manage your Docker volumes. Keep practicing, and over time these tasks will become second nature. Happy containerizing and good luck with your Docker projects!

Top comments (0)