1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

DockerのコンテナのVolumeを確認する

Last updated at Posted at 2021-10-28

以下Docker for Macが前提です。

まず該当のVolumeを突き止めるためにVolumeの一覧を取得

% docker volume ls
-> 
Driver  Volume name
local   foo
local   bar
...

次に該当のVolumeのmountpointを取得

% docker volume inspect foo
-> 
{
  "Created_at": ...,
  "Driver": "local",
  "Labels": ...,
  "Mountpoint": "/var/lib/docker/volumes/foo/_data",
  "Options": null,
  "Scope": "local"
}

docker for MacではVolumesのmountpointのディレクトリにホストOSのターミナルから入ることができないので、
Docker EngineのVMにnsenterを使ってSSHを使わずにコンテナに入る。

***** memo *****
nsenter -> ENTER Name Space
dockerが作ったNameSpaceに入るコマンド
***** memo *****

以下のコマンドでVM内に入れる。

% docker run -it --rm --privileged --pid=host justincormack/nsenter1

参考

目的のvolumeに移動。

% cd /var/lib/docker/volumes/foo/_data
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?