docker / docker/cli

[Feature] Show container name/id in volume inspect data

Open
#3,413 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Think in this scenario:

  • You have a lot of used and unused volumes in your Docker;
  • You want to remove some of these volumes, BUT not all of these, only ones;
  • Now, you have a lot of work running docker container inspect -f '{{.Mounts}}' <container_name> to see which volumes you can't remove.

My feature request is about adding a key in volume inspection to see which containers are/was using the volume.

Example:

Command: docker volume inspect 5563d398d03763587185c513997849ff1042351148745d1fd12128b7f8a68ffa
Output:

[
    {
        "CreatedAt": "2022-01-26T23:57:14-03:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/5563d398d03763587185c513997849ff1042351148745d1fd12128b7f8a68ffa/_data",
        "Name": "5563d398d03763587185c513997849ff1042351148745d1fd12128b7f8a68ffa",
        "Options": null,
        "Scope": "local",
+       "LastUsedBy": [
+           {
+               "Name": "/condescending_tereshkova",
+               "Id": "598459711eddfef88a8c3d7b60038fd5cbe8afe49f523adac17abf9bb4527c69"
+           }
+       ]
    }
]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the docker volume inspect entry point and trace how its inspection data is assembled. Compare the current output with the issue's example and determine where container name and ID data would come from. Done means volume inspection reports the containers that are or were using each volume in the shown LastUsedBy structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.