91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Docker怎么查看正在運行的容器目錄

發布時間:2023-03-29 11:25:30 來源:億速云 閱讀:158 作者:iii 欄目:開發技術

這篇文章主要介紹了Docker怎么查看正在運行的容器目錄的相關知識,內容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇Docker怎么查看正在運行的容器目錄文章都會有所收獲,下面我們一起來看看吧。

起因

為了方便操作服務器,大部分都是使用寶塔面板操作的,在寶塔中我發現面板中用來管理Docker的工具使用起來非常方便

如下圖:

Docker怎么查看正在運行的容器目錄

可以看到寶塔的面板可以直接查看和從操作容器、Compose 、Compose 模板、鏡像、網絡、存儲卷、倉庫等,但是本文主要說說在管理容器的面板有一個操作 【目錄】

Docker怎么查看正在運行的容器目錄

點擊之后可以直接進入到容器的內部,查看目錄地址發現其實就是服務器本地一個文件目錄

Docker怎么查看正在運行的容器目錄

/var/lib/docker/overlay2/這個目錄其實就是Docker容器掛載點,找到容器的掛載后就很方便了,以后復制宿主機文件到容器內部沒必要使用命令了。

從宿主機傳輸文件夾到 Docker 中的命令

docker cp 需要傳輸的文件路徑 docker名字:docker中放置文件的位置

示例:

# 將宿主機 ik 文件夾復制到名為 address_platform_pj 的容器中的 /usr/local/elasticsearch-7.3.0/plugins 路徑下面
docker cp /tmp/ik address_platform_pj:/usr/local/elasticsearch-7.3.0/plugins

如何查看容器掛載點

上面介紹的是用寶塔面板可以直接看到容器掛載點,下面介紹如何使用命令找到容器的掛載點。

需要借助 docker inspect 命令

Docker怎么查看正在運行的容器目錄

格式

docker inspect 容器名稱/容器ID

在Docker中,一個很重要的概念就是GraphDriver,它主要用于管理和維護鏡像,包括把鏡像從倉庫下載下來,到運行時把鏡像掛載起來可以被容器訪問等,都是GraphDriver去完成的。

下面是我們運行的一個rabbitmq容器,我們可以看一下他的GraphDriver,注意這里用的docker存儲驅動是overlay2

[root@iZbp1dg7mun11n29b6ndm6Z ~]# docker inspect rabbitmq
[
    {
        "Id": "75c688fade05cf116c219c98a3291681b31bd594bdee9e20ca4356de2be49d54",
        "Created": "2023-01-29T08:19:31.81602453Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "rabbitmq-server"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 29543,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2023-01-30T06:22:19.848560278Z",
            "FinishedAt": "2023-01-30T06:22:14.562177701Z"
        },
        "Image": "sha256:d445c0adc9a5596c50e5b73b8b636f79de24ad9da00671714aea768b3fa4ee9b",
        "ResolvConfPath": "/var/lib/docker/containers/75c688fade05cf116c219c98a3291681b31bd594bdee9e20ca4356de2be49d54/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/75c688fade05cf116c219c98a3291681b31bd594bdee9e20ca4356de2be49d54/hostname",
        "HostsPath": "/var/lib/docker/containers/75c688fade05cf116c219c98a3291681b31bd594bdee9e20ca4356de2be49d54/hosts",
        "LogPath": "/var/lib/docker/containers/75c688fade05cf116c219c98a3291681b31bd594bdee9e20ca4356de2be49d54/75c688fade05cf116c219c98a3291681b31bd594bdee9e20ca4356de2be49d54-json.log",
        "Name": "/rabbitmq",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "15672/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "15672"
                    }
                ],
                "5672/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "5672"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "always",
                "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/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6-init/diff:/var/lib/docker/overlay2/d1f57dc40a37ea144eda52008ce77c6a204315fd463503ebb44d738f9def02d6/diff:/var/lib/docker/overlay2/94e59be20d43ea92c6db5d340e4e487aa48173f4c437ac301cf3020231ef53df/diff:/var/lib/docker/overlay2/91ebb4d307f75386fbfa2c870770cebba9f9cec0e88c3204758386bd7231b0f9/diff:/var/lib/docker/overlay2/26ae282efeabcfc1e1b0b487a2550d7ca1504048e58fd6a244835b9616b9b3af/diff:/var/lib/docker/overlay2/55d42966a32b217c6b97ac2b04fe56a8b1434538c78abda79a1fe01cef7d7570/diff:/var/lib/docker/overlay2/b37a30724d2e5cda683b3646dfdaa589661da410e29331fd5d0396eb9a5aaa29/diff:/var/lib/docker/overlay2/487d3efd72670cb9762b0d7abc407f152f5bf39a5777cf353fc325bd79acbf19/diff:/var/lib/docker/overlay2/9bbf703d2ce4a6d1d78cc443297250cca265a1a1204620eabe104358372b5e4a/diff:/var/lib/docker/overlay2/925b67bb37abd8a6d62c5188e66f0bd28d308d10274e13ccf88bb9d1449a1fb6/diff",
                "MergedDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/merged",
                "UpperDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/diff",
                "WorkDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "ad29726ea314115baebd50cab42b12676e5074dd90b48a4a87dcda7be5da7849",
                "Source": "/var/lib/docker/volumes/ad29726ea314115baebd50cab42b12676e5074dd90b48a4a87dcda7be5da7849/_data",
                "Destination": "/var/lib/rabbitmq",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "rabbitmq",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "15672/tcp": {},
                "15691/tcp": {},
                "15692/tcp": {},
                "25672/tcp": {},
                "4369/tcp": {},
                "5671/tcp": {},
                "5672/tcp": {}
            },
            "Tty": false,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/opt/rabbitmq/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "OPENSSL_VERSION=1.1.1m",
                "OPENSSL_SOURCE_SHA256=f89199be8b23ca45fc7cb9f1d8d3ee67312318286ad030f5316aca6462db6c96",
                "OPENSSL_PGP_KEY_IDS=0x8657ABB260F056B1E5190839D9C4D26D0E604491 0x5B2545DAB21995F4088CEFAA36CEE4DEB00CFE33 0xED230BEC4D4F2518B9D7DF41F0DB4D21C1D35231 0xC1F33DD8CE1D4CC613AF14DA9195C48241FBF7DD 0x7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C 0xE5E52560DD91C556DDBDA5D02064C53641C25E5D",
                "OTP_VERSION=24.2",
                "OTP_SOURCE_SHA256=af0f1928dcd16cd5746feeca8325811865578bf1a110a443d353ea3e509e6d41",
                "RABBITMQ_DATA_DIR=/var/lib/rabbitmq",
                "RABBITMQ_VERSION=3.9.11",
                "RABBITMQ_PGP_KEY_ID=0x0A9AF2115F4687BD29803A206B73A36E6026DFCA",
                "RABBITMQ_HOME=/opt/rabbitmq",
                "RABBITMQ_LOGS=-",
                "HOME=/var/lib/rabbitmq",
                "LANG=C.UTF-8",
                "LANGUAGE=C.UTF-8",
                "LC_ALL=C.UTF-8"
            ],
            "Cmd": [
                "rabbitmq-server"
            ],
            "Image": "rabbitmq",
            "Volumes": {
                "/var/lib/rabbitmq": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "58608bd980cd569828f65ee1dbb3d86ece25313520d0a13b4d713c2207056d2b",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "15672/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "15672"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "15672"
                    }
                ],
                "15691/tcp": null,
                "15692/tcp": null,
                "25672/tcp": null,
                "4369/tcp": null,
                "5671/tcp": null,
                "5672/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "5672"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "5672"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/58608bd980cd",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "6129ccc527280178c4be39392eae262820f3dde58bb79080292ff4e4d8df2ef3",
            "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": "de078644f985fd6525e1562f58f81aa149f6e8d6fc2ed67fa648493e078e41b1",
                    "EndpointID": "6129ccc527280178c4be39392eae262820f3dde58bb79080292ff4e4d8df2ef3",
                    "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
                }
            }
        }
    }
]

可以看到容器的元數據特別的多,這里我們使用grep命令來檢索GraphDriver(圖形驅動程序),只展示8行主要信息

docker inspect rabbitmq | grep GraphDriver -A 8

示例:

[root@iZbp1dg7mun11n29b6ndm6Z ~]# docker inspect rabbitmq | grep GraphDriver -A 8
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6-init/diff:/var/lib/docker/overlay2/d1f57dc40a37ea144eda52008ce77c6a204315fd463503ebb44d738f9def02d6/diff:/var/lib/docker/overlay2/94e59be20d43ea92c6db5d340e4e487aa48173f4c437ac301cf3020231ef53df/diff:/var/lib/docker/overlay2/91ebb4d307f75386fbfa2c870770cebba9f9cec0e88c3204758386bd7231b0f9/diff:/var/lib/docker/overlay2/26ae282efeabcfc1e1b0b487a2550d7ca1504048e58fd6a244835b9616b9b3af/diff:/var/lib/docker/overlay2/55d42966a32b217c6b97ac2b04fe56a8b1434538c78abda79a1fe01cef7d7570/diff:/var/lib/docker/overlay2/b37a30724d2e5cda683b3646dfdaa589661da410e29331fd5d0396eb9a5aaa29/diff:/var/lib/docker/overlay2/487d3efd72670cb9762b0d7abc407f152f5bf39a5777cf353fc325bd79acbf19/diff:/var/lib/docker/overlay2/9bbf703d2ce4a6d1d78cc443297250cca265a1a1204620eabe104358372b5e4a/diff:/var/lib/docker/overlay2/925b67bb37abd8a6d62c5188e66f0bd28d308d10274e13ccf88bb9d1449a1fb6/diff",
                "MergedDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/merged",
                "UpperDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/diff",
                "WorkDir": "/var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/work"
            },
            "Name": "overlay2"
        },

通過查看容器詳情的GraphDriver.Data,我們可以知道有下面幾個重要目錄

  • LowerDir:image 鏡像層(鏡像本身,只讀)

  • UpperDir:容器的上層(讀寫)

  • MergedDir:容器的文件系統,使用Union FS(聯合文件系統)將lowerdir 和upperdir 合并給容器使用

  • WorkDir:容器在 宿主機的工作目錄

所以,每一個容器運行的分層的文件系統,其實都可以在宿主機中找到對應的(通常在docker安裝目錄下/var/lib/docker/overlay2)

MergedDir就是我們要找的容器掛載點,我們可以直接進入到該目錄下:

[root@iZbp1dg7mun11n29b6ndm6Z lib]# cd /var/lib/docker/overlay2/346e18c0e8e1bc04f3be2d7c848dbedd25ddd63639ff41ce6e19c8936e711db6/merged
[root@iZbp1dg7mun11n29b6ndm6Z merged]# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  plugins  proc  root  run  sbin  srv  sys  tmp  usr  var

高效傳輸文件到Docker容器

既然知道了容器的掛載點,我們可以使用Xftp或者其它工具,直接將想要放到容器的文件丟在上面傳輸,方便快捷,一步到位!

Docker怎么查看正在運行的容器目錄

關于“Docker怎么查看正在運行的容器目錄”這篇文章的內容就介紹到這里,感謝各位的閱讀!相信大家對“Docker怎么查看正在運行的容器目錄”知識都有一定的了解,大家如果還想學習更多知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

柏乡县| 聂拉木县| 石河子市| 霍林郭勒市| 双城市| 柏乡县| 哈密市| 叙永县| 弋阳县| 多伦县| 永德县| 招远市| 华池县| 望城县| 肇源县| 灵川县| 呼图壁县| 社旗县| 屏边| 正宁县| 奎屯市| 乌兰浩特市| 平利县| 闻喜县| 旌德县| 资溪县| 冷水江市| 丹棱县| 峨眉山市| 南涧| 安岳县| 思茅市| 沂水县| 池州市| 庄河市| 宁强县| 南岸区| 泽州县| 陕西省| 龙江县| 江口县|