datawhalechina / team-learning-program

主要存储Datawhale组队学习中“编程、数据结构与算法”方向的资料。
825 stars 370 forks source link

挂载文件至容器疑问 #5

Open mba1398 opened 3 years ago

mba1398 commented 3 years ago

使用如下命令挂载时,可以完成挂载,但是使用 docker inspect containerID 命令查看容器信息时, Mounts KEY 是空值,看不到配置信息,请问这是为什么呢?

docker run --rm -it --mount type=bind,source=/mnt/e/test.txt,target=/var/log/abc.txt ubuntu:18.04 bash

ps: 当前只有一个 ubuntu:18.04 容器是启动的。

khs1994 commented 3 years ago

你可以贴上 docker inspect containerID 命令的执行结果

mba1398 commented 3 years ago

win10+wsl2 环境,docker inspect 2c6521e3b598 返回信息如下:(容器启动状态下)

[
    {
        "Id": "2c6521e3b598ef17a498811a179d1a6c98a1bf2698d9502dcadb57f3054e21a1",
        "Created": "2021-04-13T15:29:28.6826693Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 1755,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-04-19T15:24:59.3640498Z",
            "FinishedAt": "2021-04-17T05:58:05.1912331Z"
        },
        "Image": "sha256:3339fde08fc3ae453e891ba0211cccec19e1f278f5a4599549740c1fd32572ed",
        "ResolvConfPath": "/var/lib/docker/containers/2c6521e3b598ef17a498811a179d1a6c98a1bf2698d9502dcadb57f3054e21a1/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/2c6521e3b598ef17a498811a179d1a6c98a1bf2698d9502dcadb57f3054e21a1/hostname",
        "HostsPath": "/var/lib/docker/containers/2c6521e3b598ef17a498811a179d1a6c98a1bf2698d9502dcadb57f3054e21a1/hosts",
        "LogPath": "/var/lib/docker/containers/2c6521e3b598ef17a498811a179d1a6c98a1bf2698d9502dcadb57f3054e21a1/2c6521e3b598ef17a498811a179d1a6c98a1bf2698d9502dcadb57f3054e21a1-json.log",
        "Name": "/crazy_moser",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/699a06c6b9346952de72ed78f36b87e8b31a958a0b9078194d4b93c4997ee836-init/diff:/var/lib/docker/overlay2/dfbf8b79cb898ce1c298b5808a778e0a7ff3dc5e6ddc4e23cf2d41c84893b661/diff:/var/lib/docker/overlay2/7dddc1b16adb479005ed06f57b48dcc84ec73d43de5e11bfed5f5f7c8ce041a1/diff:/var/lib/docker/overlay2/cb3adfff2b125d26c3fc5225d35cf761cca77f8b91e7b1945ef3a681bb26996a/diff",
                "MergedDir": "/var/lib/docker/overlay2/699a06c6b9346952de72ed78f36b87e8b31a958a0b9078194d4b93c4997ee836/merged",
                "UpperDir": "/var/lib/docker/overlay2/699a06c6b9346952de72ed78f36b87e8b31a958a0b9078194d4b93c4997ee836/diff",
                "WorkDir": "/var/lib/docker/overlay2/699a06c6b9346952de72ed78f36b87e8b31a958a0b9078194d4b93c4997ee836/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "2c6521e3b598",
            "Domainname": "",
            "User": "",
            "AttachStdin": true,
            "AttachStdout": true,
            "AttachStderr": true,
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": true,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "Image": "ubuntu:18.04",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "desktop.docker.io/wsl-distro": "Ubuntu-20.04"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "ed7cf97c9944c6255ad86f08ab8759f494587e76752da2ce5d0cea9d1e03dd64",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/ed7cf97c9944",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "5c4a9255dce099d46f407161da3376c9d3a56407727701060e45d7c77f573a92",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "47242c4a4a9ec82e00d7143cc084cc8b5323e95a9a8babb13efb60808c9f832a",
                    "EndpointID": "5c4a9255dce099d46f407161da3376c9d3a56407727701060e45d7c77f573a92",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]