Docker所在目录以及查询正在运行容器的所在位置

一、获取正在运行的容器ID

[root@izuf60j0xye9c3vxjqujjiz ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                        NAMES
420e68110642        df6f26ea3e53        "docker-entrypoint..."   2 months ago        Up 2 months         4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp   myRabbitMQ
3e27d4875c06        redis               "docker-entrypoint..."   2 months ago        Up 2 months         0.0.0.0:6379->6379/tcp                                                                       MyRedis
a21ff6066359        mysql:5.5           "docker-entrypoint..."   2 months ago        Up 2 months         0.0.0.0:3306->3306/tcp                                                                       myMysql
7ebcbd1342c6        tomcat              "catalina.sh run"        2 months ago        Up 2 months         0.0.0.0:8088->8080/tcp                                                                       myTomcat

二、复制容器ID并查询

//以MyRedis为例
[root@izuf60j0xye9c3vxjqujjiz local]# docker inspect 3e27d4875c06
[
    {
        "Id": "3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a",
        "Created": "2019-04-21T04:13:06.774375263Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "redis-server"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 14646,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-04-21T04:13:06.983559768Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:a55fbf438dfd878424c402e365ef3d80c634f07d0f5832193880ee1b95626e4e",
        "ResolvConfPath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/hostname",
        "HostsPath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/hosts",
        "LogPath": "",
        "Name": "/MyRedis",
        "RestartCount": 0,
        "Driver": "overlay2",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
    }
]

1、Path后面的值即为该运行容器的位置:

"Path": "docker-entrypoint.sh"

2、HostPath后面的值即为docker容器所在位置:

"HostnamePath": "/var/lib/docker/containers/3e27d4875c06f26562caf9d26d01c24d0a6fae6c5710bc23e429825844fc5f3a/hosts"

 

你可能感兴趣的:(Linux专区,服务器)