Centos7 Docker查看容器IP地址_入门试炼07

一、查看容器IP地址

1. 查看容器运行的各种数据

 docker inspect mycentos3

Centos7 Docker查看容器IP地址_入门试炼07_第1张图片
Centos7 Docker查看容器IP地址_入门试炼07_第2张图片

2. 查看容器ip

docker inspect --format='{{.NetworkSettings.IPAddress}}' mycentos3

获取其他信息,找到获取信息的节点,同理
在这里插入图片描述

执行docker inspect mycentos3后的所有内容:

[root@localhost ~]#  docker inspect mycentos3
[
    {
        "Id": "d43c8ce553692521318bdd3c84528b4910ccb88d6ff5142eaed8845d740eb35e",
        "Created": "2020-03-01T04:53:48.720669793Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 8296,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-03-01T04:53:48.955511003Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:5e35e350aded98340bc8fcb0ba392d809c807bc3eb5c618d4a0674d98d88bccd",
        "ResolvConfPath": "/var/lib/docker/containers/d43c8ce553692521318bdd3c84528b4910ccb88d6ff5142eaed8845d740eb35e/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/d43c8ce553692521318bdd3c84528b4910ccb88d6ff5142eaed8845d740eb35e/hostname",
        "HostsPath": "/var/lib/docker/containers/d43c8ce553692521318bdd3c84528b4910ccb88d6ff5142eaed8845d740eb35e/hosts",
        "LogPath": "",
        "Name": "/mycentos3",
        "RestartCount": 0,
        "Driver": "overlay2",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": [
            "50cd4efdc7dc7644ae008aa01943856a738462b6abf05b270d6b80272e058e13",
            "ddf2063f8d1b082a7c988661d7ce8171638198294419d80e0bf493dde481ea0f",
            "b8c5c335dafbe356430646e110fa6c6f7e2cfa9a0950860baa50cc63daa3ec10"
        ],
        "HostConfig": {
            "Binds": [
                "/usr/local/myhtml/:/usr/local/nh"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "journald",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": true,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": [
                "label=disable"
            ],
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "docker-runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0
        },
        "GraphDriver": {
            "Name": "overlay2",
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/6bbf97d7285faead43c4fbf897a616d239a963ce74b4222d0521411b2778df1b-init/diff:/var/lib/docker/overlay2/ffc6a4499cd2288ab5f60f3ef14440b93f476ae372563bc15a0086a02632fc41/diff",
                "MergedDir": "/var/lib/docker/overlay2/6bbf97d7285faead43c4fbf897a616d239a963ce74b4222d0521411b2778df1b/merged",
                "UpperDir": "/var/lib/docker/overlay2/6bbf97d7285faead43c4fbf897a616d239a963ce74b4222d0521411b2778df1b/diff",
                "WorkDir": "/var/lib/docker/overlay2/6bbf97d7285faead43c4fbf897a616d239a963ce74b4222d0521411b2778df1b/work"
            }
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/usr/local/myhtml",
                "Destination": "/usr/local/nh",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "d43c8ce55369",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "ArgsEscaped": true,
            "Image": "centos:7",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20191001",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "f6a28e9e7239376e3fbb7ac7169363cbaf924737559e7a667031de6fb653b6bd",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/f6a28e9e7239",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "a0a6c0ff3db1016f88f9fef238516ee0d6fb64f3038adc07b260f22f0a1b72ad",
            "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": "bf45b9ba1f8fba4bad3833bd70cb510307208ef2d909d9545481400a022027c8",
                    "EndpointID": "a0a6c0ff3db1016f88f9fef238516ee0d6fb64f3038adc07b260f22f0a1b72ad",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02"
                }
            }
        }
    }
]
[root@localhost ~]# 

想学习更多微服务、分布式、中间件、数据库、项目快速构建等系列技术
请访问Gblfy主页:https://blog.csdn.net/weixin_40816738
让我们一起进步!!!

你可能感兴趣的:(Docker)