English 中文(简体)
如何看待对集装箱的捆绑大小?
原标题:How to view the bind mounts for a docker container?

How do I see what the bind mounts are for a given container? Something like docker volume ls, but for bind mounts.

问题回答

docker Inspection 不结盟运动><>/code>

e.g.,
docker inspect my_container_id

This will give a lot of low-level information about the container, including the bind mounts. Search the output for Mounts.

实例:

$ docker inspect my_container_name
...
"Mounts": [
    {
        "Type": "bind",
        "Source": "/Users/my_user/my_dir_to_mount",
        "Destination": "/my_mount",
        "Mode": "",
        "RW": true,
        "Propagation": "rprivate"
    },
    {
        "Type": "volume",
        "Name": "vscode",
        "Source": "/var/lib/docker/volumes/vscode/_data",
        "Destination": "/vscode",
        "Driver": "local",
        "Mode": "z",
        "RW": true,
        "Propagation": ""
    }
],
...
    "Mounts": [
        {
            "Type": "bind",
            "Source": "/Users/my_user/my_dir_to_mount",
            "Target": "/my_mount",
            "Consistency": "cached"
        },
        {
            "Type": "volume",
            "Source": "vscode",
            "Target": "/vscode"
        }
],

$ # in  gron  format ( gron  =  grep-able JSON :
$ docker inspect my_container_name | gron | grep Mounts
json[0].HostConfig.Mounts = [];
json[0].HostConfig.Mounts[0] = {};
json[0].HostConfig.Mounts[0].Consistency = "cached";
json[0].HostConfig.Mounts[0].Source = "/Users/my_user/my_dir_to_mount";
json[0].HostConfig.Mounts[0].Target = "/my_mount";
json[0].HostConfig.Mounts[0].Type = "bind";
json[0].HostConfig.Mounts[1] = {};
json[0].HostConfig.Mounts[1].Source = "vscode";
json[0].HostConfig.Mounts[1].Target = "/vscode";
json[0].HostConfig.Mounts[1].Type = "volume";
json[0].Mounts = [];
json[0].Mounts[0] = {};
json[0].Mounts[0].Destination = "/my_mount";
json[0].Mounts[0].Mode = "";
json[0].Mounts[0].Propagation = "rprivate";
json[0].Mounts[0].RW = true;
json[0].Mounts[0].Source = "/Users/my_user/my_dir_to_mount";
json[0].Mounts[0].Type = "bind";
json[0].Mounts[1] = {};
json[0].Mounts[1].Destination = "/vscode";
json[0].Mounts[1].Driver = "local";
json[0].Mounts[1].Mode = "z";
json[0].Mounts[1].Name = "vscode";
json[0].Mounts[1].Propagation = "";
json[0].Mounts[1].RW = true;
json[0].Mounts[1].Source = "/var/lib/docker/volumes/vscode/_data";
json[0].Mounts[1].Type = "volume";




相关问题
Unable to connect to docker container inside windows server

As title. I am developing a system with many docker images with ASP.Net MVC core projects. I am publishing these docker images into a docker engine installed on Windows Server OS, and I found that I ...

Only can see postgreSQL as an admin

After installed Wsl and Docker, can t access PSQL and other things. I was studying Docker, and installed the latest version. So far so good, I received an error about the WSL version, saw some ...

make docker-compose block until healthy without `depends_on`

I am working with a team that uses docker-compose to start a set of helper services, but does not use docker when the code is being developed. Here, docker-compose is just a convenient way to run the ...

change grafana port using docker host network

I am trying to spin up a grafana container in docker, however my setup in docker does not allow ipv4 forwarding and thus I cannot use the default bridge network in docker. All I can use is the host ...

Pip instalation for Python 3.11 in docker

I have Dockerfile to build image for Django project that uses Python 3.11 and runs in poetry environment (see content below). Problem is when I try to donwload get-pip.py file and run it using Python, ...

在 Dockerfile 中运行 composer install

我正在尝试将我的Laravel应用程序进行Docker化。 该应用程序已经构建并在Git中,但我将vendor文件夹添加到了.gitignore中。 我添加了一个Dockerfile,看起来像这样: FROM php:7.1-fpm-alpine RUN apk update ...