docker inspect 容器名,可以查看到容器的元信息,在返回的j'son信息里面有个Mounts字段可以看到挂载目录

        "Mounts": [
            {
                "Type": "bind",
                "Source": "/data1/cmsphp",
                "Destination": "/data1",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/data1/ftp/public/src/cms",
                "Destination": "/data1/ms",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ]

可以看到宿主机是/data1/cmsphp   挂载到容器 /data1

宿主机/data1/ftp/public/src/cms  挂载到容器 /data1/ms

完整信息:

[root@localhost log]# docker inspect cmsphp
[
    {
        "Id": "8de99c8b2a9d6e6ef65302f39153a161a21df0f477bb12bdd0343441b6e35bcd",
        "Created": "2020-02-22T15:19:27.031944204Z",
        "Path": "/run.sh",
        "Args": [
            "php-fpm",
            "--nodaemonize"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 10656,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-02-22T15:19:27.827341786Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:24f1fd58634ae496cdbb889c6d42397e6914255c7f86180cbc7207892f8e5ac3",
        "ResolvConfPath": "/var/lib/docker/containers/8de99c8b2a9d6e6ef65302f39153a161a21df0f477bb12bdd0343441b6e35bcd/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/8de99c8b2a9d6e6ef65302f39153a161a21df0f477bb12bdd0343441b6e35bcd/hostname",
        "HostsPath": "/var/lib/docker/containers/8de99c8b2a9d6e6ef65302f39153a161a21df0f477bb12bdd0343441b6e35bcd/hosts",
        "LogPath": "/var/lib/docker/containers/8de99c8b2a9d6e6ef65302f39153a161a21df0f477bb12bdd0343441b6e35bcd/8de99c8b2a9d6e6ef65302f39153a161a21df0f477bb12bdd0343441b6e35bcd-json.log",
        "Name": "/cmsphp",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/data1/cmsphp/:/data1/",
                "/data1/ftp/public/src/cms/:/data1/ms/"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "9000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "9001"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Capabilities": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": [
                "locfront.sina.com.cn:10.23.3.227",
                "ds.uscms.pub.sina.com.cn:10.23.3.226"
            ],
            "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/49307940dcdb643286a0b4080dab70993e24aa499df60a920221630fbb5d634e-init/diff:/var/lib/docker/overlay2/d5b75bc6a7da35cabed94b9823fa1eb41802533b540d8a568b083bea5cac666d/diff:/var/lib/docker/overlay2/0cf2d3d2f30ebdb7a6ea54c5bc46d7f66f8e84fe4aaea7b8af7e6c56086e549d/diff:/var/lib/docker/overlay2/996361ec9516b992b6562560985bc4ffa3d7ffcde94d277ecbbaf6a61a9b0a54/diff:/var/lib/docker/overlay2/35fb38c04eabeebf21de3717bb5b2a2e13d6df3555916b046fd1d90ff7c16abb/diff:/var/lib/docker/overlay2/16c97b27b72b2bcd33ddbad49cef97801366a237f78b34c728007ebd821ec8ef/diff:/var/lib/docker/overlay2/c4d05fcafb5a08f5a6b14d6ca93711bc034e8bebeb637101c339a3b821e71e31/diff:/var/lib/docker/overlay2/786099514d19740e956c8432ab5ca8ee61141d7c77c758cc00348e1df722e94f/diff:/var/lib/docker/overlay2/3c59d443fdb1d910bd815d8be06ff41bc78171f74c67c15b57c2532baab71ff4/diff:/var/lib/docker/overlay2/2bd3d05194285297b54a0f77af6c08a8c8306502193d96bfe0321da0ccf96347/diff:/var/lib/docker/overlay2/747be5f7344f4c51b0196ff6be4ead6fea4dc05d2e707576b8cb808a19cfe693/diff:/var/lib/docker/overlay2/7f0ae842527d6aae43c41b0661fa3894764966748e50962f6ead696d8e074cc1/diff:/var/lib/docker/overlay2/04782b00fbe8b31279f1ea9c5021cd596a7ab7586e69c0771f16c829b1251567/diff:/var/lib/docker/overlay2/98bc05305659159b6b419ff12737d1f034599c38a19652df0603a2a8c574fe05/diff:/var/lib/docker/overlay2/f6ffb61f08ebf053154f774018c3684b88c6426873362823e2848a9a615facc2/diff",
                "MergedDir": "/var/lib/docker/overlay2/49307940dcdb643286a0b4080dab70993e24aa499df60a920221630fbb5d634e/merged",
                "UpperDir": "/var/lib/docker/overlay2/49307940dcdb643286a0b4080dab70993e24aa499df60a920221630fbb5d634e/diff",
                "WorkDir": "/var/lib/docker/overlay2/49307940dcdb643286a0b4080dab70993e24aa499df60a920221630fbb5d634e/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/data1/cmsphp",
                "Destination": "/data1",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/data1/ftp/public/src/cms",
                "Destination": "/data1/ms",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "8de99c8b2a9d",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "9000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHPIZE_DEPS=autoconf \t\tdpkg-dev dpkg \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkgconf \t\tre2c",
                "PHP_INI_DIR=/usr/local/etc/php",
                "PHP_EXTRA_CONFIGURE_ARGS=--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi",
                "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
                "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
                "PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie",
                "GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312",
                "PHP_VERSION=7.4.1",
                "PHP_URL=https://www.php.net/get/php-7.4.1.tar.xz/from/this/mirror",
                "PHP_ASC_URL=https://www.php.net/get/php-7.4.1.tar.xz.asc/from/this/mirror",
                "PHP_SHA256=561bb866bdd509094be00f4ece7c3543ec971c4d878645ee81437e291cffc762",
                "PHP_MD5="
            ],
            "Cmd": [
                "php-fpm",
                "--nodaemonize"
            ],
            "Image": "sinamess/php",
            "Volumes": null,
            "WorkingDir": "/var/www/html",
            "Entrypoint": [
                "/run.sh"
            ],
            "OnBuild": null,
            "Labels": {},
            "StopSignal": "SIGQUIT"
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "fd003aa0da95f80dd2ca451b8328c5ffd07f25c554963eb4db60cd4fed5da6fb",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "9000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "9001"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/fd003aa0da95",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "deee664fb763a1c5e22a028814bb74f8d35f99ac178d667c5c1401cd5c37fd14",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.7",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:07",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "8cff241007ebcdedde49d32b0dfa0dad5c0a6316c87e53e40ae3029403d8282a",
                    "EndpointID": "deee664fb763a1c5e22a028814bb74f8d35f99ac178d667c5c1401cd5c37fd14",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.7",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:07",
                    "DriverOpts": null
                }
            }
        }
    }
]

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐