Open In App

What Is Docker Volume Inspect ?

Last Updated : 11 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

“docker volume inspect” is a command line interface (CLI) used to extract detailed information about Docker volume. Docker volumes are mainly used to maintain the state of the application which means in other words it is used for the stateful applications.

What Is Docker Volume?

Docker volume is a way to manage the state of the containerized application which other docker containers can reuse they can be reusable with other containers. Data of the application will persist even if the container associated with that volume is stopped or even removed.

Docker volume will mainly used for applications that maintain stateful data share data between containers, or ensure data durability.

How To List All the Docker Volumes

To list all the docker volumes that are present in the docker host you can use the below command.

docker volume list

docker volume ls

In the above image you can see that one volume was present and the driver used to create that volume was the local driver.

Types Of Docker Volume Drivers

Following are some types of docker types of docker volume drivers

  • Local Driver: The default volume driver that creates volumes on the local host. This driver is suitable for basic local storage needs and is often used during development.
  • Named Volume: Named volumes are a type of local volume that Docker manages. They provide a more abstract and portable way to handle storage, allowing you to refer to volumes by name rather than a specific host path
  • Bind Mount: Bind mounts directly reference a directory on the host machine. They are useful for sharing files between the host and containers or for persisting data in a specific location on the host.

Steps To Inspect Docker Volume

Follow the steps mentioned below to see all the docker volumes avalible in the docker host

Step 1: List all the docker volumes with the help of below command.

Step 2: To inspect that volume you can use the below command as showin the image below.

docker volume inspect <Name of the volume>

Here i am using the following command because the name of the volume was GFG-Volume.

docker volume inspect GFG-Volume.

docker volume inspect

Why We Need to Inspect the Docker Volume

Docker volume inspect will shows you the following details i will take an example of the things shown in my docker volume and explain in detail.

docker volume inspect provides the following output,

  • CreatedAt: The timestamp indicating when the Docker volume was created. In this example, the volume was created on February 24, 2024, at 03:31:58 UTC.
  • Driver: The volume driver used for this Docker volume. In this case, the driver is “local,” which is the default driver for local volumes.
  • Labels: Docker volumes can have labels associated with them for metadata purposes. In this example, the “Labels” field is null, indicating that no labels are defined for this volume.
  • Mountpoint: The path on the host system where the volume is mounted. In this case, the volume named “GFG-Volume” is mounted at “/var/lib/docker/volumes/GFG-Volume/_data.”
  • Name: The name of the Docker volume. In this example, the volume is named “GFG-Volume.”
  • Options: Additional options or configurations for the volume. In this example, the “Options” field is null, indicating that no specific options are defined for this volume.
  • Scope: The scope of the volume. In this case, the scope is “local,” indicating that the volume is specific to the local Docker host.

Dcoker Volume Inspect Verbose

The “docker volume inspect” command in Docker is used to display detailed information about a specified volume. You can use the docker volume inspect with the other commands for more detailed information such as.

docker volume inspect my_volume | jq

To get the output in the jason format you can use the “jq”.If you don’t have jq installed, you can simply use standard Linux commands to view the information:

docker volume inspect my_volume | cat

This will display the raw JSON output of the volume inspection. You can adjust these commands based on your specific needs and the information you’re looking to extract from the volume configuration.

Docker Volume Inspect – FAQ’s

Can I access a docker volume?

Yes, you can access the contents of a Docker volume directly on the host machine where Docker is running. Docker volumes are typically mounted at specific paths on the host, allowing you to read or modify the data stored in those volumes.

How do I inspect a docker container file?

To inspect the file in the docker container use the following command.

docker exec -it your_container_name_or_id cat /path/to/your/file.txt

Can I access a docker volume?

Yes, you can access the contents of a Docker volume outside of the container. Docker volumes are designed to persist data beyond the lifecycle of a container and can be mounted to other containers or accessed directly from the host machine.

Linux: Volumes are typically stored in /var/lib/docker/volumes/. Default path in linux.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads