对于运行在Docker环境的容器,有时我们想查询它们的一些基本信息,例如环境变量、hostname、ip地址等,接下来我们以一个tomcat容器为例,看看有哪些方式来取得这些信息;

原文地址: https://blog.csdn.net/boling_cavalry/article/details/80215214

创建tomcat容器

在docker环境下执行如下命令,即可创建一个名为tomcat001的tomcat容器:

docker run --name tomcat001 -idt tomcat

执行docker ps检查一下,容器创建成功:

root@maven:~# docker ps
CONTAINER ID	IMAGE	COMMAND				CREATED			STATUS			PORTS		NAMES
98d119ed4c73	tomcat	"catalina.sh run"	10 minutes ago	Up 10 minutes	8080/tcp	tomcat001

获取信息常用的方式有如下三种:

  1. 进入容器内部获取信息;
  2. 执行docker exec命令;
  3. 执行docker inspect -f命令(推荐方式)

第一种:进入容器内部获取信息

执行以下命令可进入容器内部:

docker exec -it tomcat001 /bin/bash

此时已进入容器内部,所以分别执行hostname、ip addr、env这三个命令可以获取相关信息,如下:

root@98d119ed4c73:/usr/local/tomcat# hostname
98d119ed4c73
root@98d119ed4c73:/usr/local/tomcat# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:05 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.5/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:5/64 scope link 
       valid_lft forever preferred_lft forever
root@98d119ed4c73:/usr/local/tomcat# env
LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib
CATALINA_HOME=/usr/local/tomcat
LANG=C.UTF-8
HOSTNAME=98d119ed4c73
OPENSSL_VERSION=1.1.0f-3+deb9u1
TOMCAT_VERSION=8.5.24
GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
JAVA_HOME=/docker-java-home/jre
TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib
JAVA_VERSION=8u151
PWD=/usr/local/tomcat
HOME=/root
CA_CERTIFICATES_JAVA_VERSION=20170531+nmu1
TOMCAT_MAJOR=8
JAVA_DEBIAN_VERSION=8u151-b12-1~deb9u1
TOMCAT_SHA1=9e26ba61c5665aafc849073edeb769be555283cd
TERM=xterm
SHLVL=1
TOMCAT_ASC_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc      https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc    https://www.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc       https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc
PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TOMCAT_TGZ_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz  https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz        https://www.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz   https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz
_=/usr/bin/env

第二种:执行docker exec命令

不用进入容器,直接在docker环境执行docker exec 容器名 容器内命令的方式也可以获取相关信息,举例如下:

  1. 获取容器的hostname:docker exec tomcat001 hostname
  2. 获取容器ip地址:docker exec tomcat001 ip addr
  3. 获取容器环境变量:docker exec tomcat001 env

执行结果如下所示:

root@maven:~# docker exec tomcat001 hostname
98d119ed4c73
root@maven:~# docker exec tomcat001 ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:05 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.5/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:5/64 scope link 
       valid_lft forever preferred_lft forever
root@maven:~# docker exec tomcat001 env
PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=98d119ed4c73
LANG=C.UTF-8
JAVA_HOME=/docker-java-home/jre
JAVA_VERSION=8u151
JAVA_DEBIAN_VERSION=8u151-b12-1~deb9u1
CA_CERTIFICATES_JAVA_VERSION=20170531+nmu1
CATALINA_HOME=/usr/local/tomcat
TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib
LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib
OPENSSL_VERSION=1.1.0f-3+deb9u1
GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
TOMCAT_MAJOR=8
TOMCAT_VERSION=8.5.24
TOMCAT_SHA1=9e26ba61c5665aafc849073edeb769be555283cd
TOMCAT_TGZ_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz  https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz        https://www.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz   https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz
TOMCAT_ASC_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc      https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc    https://www.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc       https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc
HOME=/root

第三种:使用docker inspect命令

推荐使用docker inspect来获取信息,这个命令会返回一个json字符串,里面以key-value的格式准备了该容器相关的信息,内容十分丰富,可以一次性取得全部内容,也可以返回指定key对应的信息;

我们先来看看所有内容,执行命令docker inspect tomcat001,可以看到如下信息:

root@maven:~# docker inspect tomcat001
        "Id": "98d119ed4c73c750e53353e77f7c6942803809a9d5dedc28d8b0f41ce58b8b17",
        "Created": "2018-05-06T07:39:45.464492435Z",
        "Path": "catalina.sh",
        "Args": [
            "run"
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 22468,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-05-06T07:39:46.143092505Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        "Image": "sha256:3dcfe809147daf54fbdbe1f6886b4c49df63f28e2b3c8ac119fef6a7f7490d3c",
        "ResolvConfPath": "/var/lib/docker/containers/98d119ed4c73c750e53353e77f7c6942803809a9d5dedc28d8b0f41ce58b8b17/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/98d119ed4c73c750e53353e77f7c6942803809a9d5dedc28d8b0f41ce58b8b17/hostname",
        "HostsPath": "/var/lib/docker/containers/98d119ed4c73c750e53353e77f7c6942803809a9d5dedc28d8b0f41ce58b8b17/hosts",
        "LogPath": "/var/lib/docker/containers/98d119ed4c73c750e53353e77f7c6942803809a9d5dedc28d8b0f41ce58b8b17/98d119ed4c73c750e53353e77f7c6942803809a9d5dedc28d8b0f41ce58b8b17-json.log",
        "Name": "/tomcat001",
        "RestartCount": 0,
        "Driver": "aufs",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": [
            "cffec99f38514024f6a6e31e0e160d37d295041e4813a2245466be2dbc9c4037"
        "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,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
            "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": "aufs",
            "Data": null
        "Mounts": [],
        "Config": {
            "Hostname": "98d119ed4c73",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/tomcat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "JAVA_HOME=/docker-java-home/jre",
                "JAVA_VERSION=8u151",
                "JAVA_DEBIAN_VERSION=8u151-b12-1~deb9u1",
                "CA_CERTIFICATES_JAVA_VERSION=20170531+nmu1",
                "CATALINA_HOME=/usr/local/tomcat",
                "TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
                "LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
                "OPENSSL_VERSION=1.1.0f-3+deb9u1",
                "GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23",
                "TOMCAT_MAJOR=8",
                "TOMCAT_VERSION=8.5.24",
                "TOMCAT_SHA1=9e26ba61c5665aafc849073edeb769be555283cd",
                "TOMCAT_TGZ_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz \thttps://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz \thttps://www.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz \thttps://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz",
                "TOMCAT_ASC_URLS=https://www.apache.org/dyn/closer.cgi?action=download&filename=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc \thttps://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc \thttps://www.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc \thttps://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz.asc"
            "Cmd": [
                "catalina.sh",
                "run"
            "ArgsEscaped": true,
            "Image": "tomcat",
            "Volumes": null,
            "WorkingDir": "/usr/local/tomcat",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "50244517221e6faff4217ff5453919f0c297b10434812ecfbf3decb3ce9860f6",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8080/tcp": null
            "SandboxKey": "/var/run/docker/netns/50244517221e",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "e9336feece03b1c87e6724253575ee50963e9bdc1f9618609fe641a8a939b87a",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.5",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:05",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "87eb4d08d408c08489db4460915aabed59210d04f8193364420d3719cd308d83",
                    "EndpointID": "e9336feece03b1c87e6724253575ee50963e9bdc1f9618609fe641a8a939b87a",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.5",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:05"

可见内容十分丰富;

如果我们只对其中的一些感兴趣,例如hostname、ip地址、环境变量,该如何查看呢?

  1. hostname:在返回值中,hostname的位置如下图红框所示,
    这里写图片描述
    由上图可见,hostname位于Config.Hostname这个节点位置,所以执行命令docker inspect -f {{.Config.Hostname}} tomcat001即可获取到hostname,如下所示:
root@maven:~# docker inspect -f {{.Config.Hostname}} tomcat001
98d119ed4c73
  1. ip地址:执行命令docker inspect -f {{.NetworkSettings.IPAddress}} tomcat001即可获取到ip地址:
root@maven:~# docker inspect -f {{.NetworkSettings.IPAddress}} tomcat001
172.17.0.5
  1. 环境变量:从完整的inspect信息中可以看到环境变量Config.Env的内容是个json数组,所以除了用docker inspect -f {{.Config.Env}} tomcat001获取所有环境变量信息,还可以用docker inspect -f ‘{{index .Config.Env 1}}’ tomcat001命令获取数组中的某一条记录,如下:
root@maven:~# docker inspect -f '{{index .Config.Env 1}}' tomcat001
LANG=C.UTF-8
root@maven:~# docker inspect -f '{{index .Config.Env 2}}' tomcat001 
JAVA_HOME=/docker-java-home/jre

至此,三种获取容器信息的方式已经全部列出,之所以在本文中推荐第三种,是因为有时我们会在shell脚本中获取容器信息,这时候用这种方式最为简单;

欢迎关注我的公众号:程序员欣宸

对于运行在Docker环境的容器,有时我们想查询它们的一些基本信息,例如环境变量、hostname、ip地址等,接下来我们以一个tomcat容器为例,看看有哪些方式来取得这些信息;原文地址:https://blog.csdn.net/boling_cavalry/article/details/80215214创建tomcat容器在docker环境下执行如下命令,即可创建一个名为t... 2.1 找出Docker容器日志 在linux上,容器日志一般存放在/var/lib/docker/containers/container_id/下面, 以json.log结尾的文件(业务日志)很大,查看各个日志文件大小的脚本docker_log_size.sh,内容如下: #!/bin/sh echo ======== docker containers logs file size ========
在nodejs环境中测试通过,其它语言同理,只需要使用获取环境变量的方法即可。 思路:docker容器和宿主机环境是隔离的,但是可以在启动docker容器时将宿主机的主机名以环境变量的形式传入,代码在容器中获取该值即可。 docker run -d -p 3000:3000 --name myTest -e HOST_Q=$(hostname) mytest:v1 # 使用-e ...
查看Docker容器信息 对于运行在Docker环境的容器,有时我们想查询它们的一些基本信息,例如环境变量、hostname、ip地址等,接下来我们以一个tomcat容器为例,看看有哪些方式来取得这些信息; 创建tomcat容器docker环境下执行如下命令,即可创建一个名为tomcat001的to 在没使用 helm 之前,向 kubernetes 部署应用,我们要依次部署 deployment、svc 等,步骤较繁琐。 况且随着很多项目微服务化,复杂的应用在容器中部署以及管理显得较为复杂,helm 通过打包的方式,支持发布的版本管理和控制, 很大程度上简化了 Kubernetes 应用的部署和管理。 Helm 本质就是让 K8s 的应用管理(Deploymen、Service 等)可配置,可以通过类似于传递环境变量的方式能动态生成。通过动...
本书根据Docker 1.10版和Kubernetes 1.2版对第1版进行了全面更新,从实践者的角度出发,以Docker和Kubernetes为重点,沿着“基本用法介绍”到“核心原理解读”到“高级实践技巧”的思路,一本书讲透当前主流的容器容器云技术,有助于读者在实际场景中利用Docker容器容器云解决问题并启发新的思考。全书包括两部分,第一部分深入解读Docker容器技术,包括Docker架构与设计、核心源码解读和高级实践技巧;第二部分归纳和比较了三类基于Docker的主流容器云项目,包括专注Docker容器编排与部署的容器云、专注应用支撑的容器云以及一切皆容器的Kubernetes,进而详细解读了Kubernetes核心源码的设计与实现,最后介绍了几种典型场景下的Kubernetes最佳实践。
方式一、虚拟ip访问 安装docker时,docker会默认创建一个内部的桥接网络docker0,每创建一个容器分配一个虚拟网卡,容器之间可以根据ip互相访问。 [root@33fcf82ab4dd /]# [root@CentOS ~]# ifconfig ...... docker0: flags=4163<UP> mtu 1500 inet 172.17.0.1 netmask 255.255
容器的使用过程中,如果能及时的掌握容器使用的系统资源,无论对开发还是运维工作都是非常有益的。幸运的是 docker 自己就提供了这样的命令:docker stats。 docker stats 命令用来显示容器使用的系统资源。不带任何选项执行 docker stats 命令: $ docker stats 默认情况下,stats 命令会每隔 1 秒钟刷新一次输出的内容直到你按下 ctrl + c。下面是输出的主要内容: [CONTAINER]:以短格式显示容器的 ID。 [CPU %]:CPU 的使用情况。 [MEM USAGE / LIMIT]:当前使用的内存和最大可以使用
见:http://doc.okbase.net/ylchou/archive/186545.htmldocker rename old容器名 new容器名[root@ylchou ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS ...
Dockerdocker 使用helloworld流程底层原理docker是怎么工作的docker为什么比虚拟机快Docker的常用命令帮助命令镜像命令容器命令常用的其他命令容器数据卷什么是容器数据卷使用数据卷DockerFileDockerFile指令测试实战:tomcat镜像发布自己的镜像Docker网络理解Docker0自定义网络实战:Redis集群测试 docker 使用 helloworld流程 运行原理图 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-m7hh
docker inspect --format='{{.State.StartedAt}}' <容器名称或ID> | xargs -I{} date --date={} +%Y-%m-%d_%H:%M:%S 这个命令可以输出指定Docker容器的开始时间和当前时间。通过计算便能得到Docker容器的实时时间。