首页 > 其他分享 >Docker基础:容器元数据详解

Docker基础:容器元数据详解

时间:2022-10-22 23:04:10浏览次数:63  
标签:容器 lib overlay2 详解 var Docker null docker


Docker基础:容器元数据详解_docker

今天给大家介绍Docker容器元数据里面包含内容详解,如有不当之处,欢迎大家指正。

查看容器元数据主要通过docker inspect 容器id进行查看。今天通过docker安装的mysql查看启动的容器。

1、命令格式

docker inspect \[OPTIONS\] NAME|ID \[NAME|ID...\]

命令选项

名称

默认值

描述

--format , -f


格式化输出

--size , -s


显示的最大文件大小

--type


返回指定类型的 JSON

使用 inspect 命令可以查看一个容器的具体信息。

2、用法介绍

2.1 查看IP地址

docker inspect --format='\{ \{range .NetworkSettings.Networks\}\}\{ \{.MacAddress\}\}\{ \{end\}\}' 572219d3a0ca

[root@ecs-337444 ~]# docker inspect --format='{


{


range .NetworkSettings.Networks}}{


{


.MacAddress}}{


{


end}}' 572219d3a0ca
02:42:ac:11:00:03

2.2 查看MAC地址

docker inspect --format='\{ \{range .NetworkSettings.Networks\}\}\{ \{.IPAddress\}\}\{ \{end\}\}' 572219d3a0ca

[root@ecs-337444 ~]# docker inspect --format='{


{range .NetworkSettings.Networks}}{


{.IPAddress}}{


{end}}' 572219d3a0ca
172.17.0.3

2.3 查看容器详细信息

docker inspect 572219d3a0ca

下面把能找到资料的参数解释给大家标注一下,大家有不同意见的欢迎留言我会及时更正。

[
{



"Id": "572219d3a0ca25a37623a1113f3c8faa6b48d3ab42ae668eac64fcb39cb4dd84", #完整容器id
"Created": "2022-06-08T08:29:58.542781937Z", #容器创建时间
"Path": "docker-entrypoint.sh", #启动容器时,通过shell脚本执行些预处理逻辑中shell脚本的名称
"Args": [
"mysqld"
],
"State": {



"Status": "running", #容器状态
"Running": true, #是否运行
"Paused": false, #是否暂停
"Restarting": false, #是否重启中
"OOMKilled": false, #进程被杀死
"Dead": false, # 已小王
"Pid": 136172, # 容器进程id
"ExitCode": 0, # 退出状态码
"Error": "", #错误信息
"StartedAt": "2022-07-16T01:47:33.598196195Z", #开始启动时间
"FinishedAt": "2022-07-16T01:47:26.919749746Z" # 上一次结束时间
},
"Image": "sha256:3218b38490cec8d31976a40b92e09d61377359eab878db49f025e5d464367f3b", #镜像的sha256算法id
"ResolvConfPath": "/var/lib/docker/containers/572219d3a0ca25a37623a1113f3c8faa6b48d3ab42ae668eac64fcb39cb4dd84/resolv.conf", # resolv.conf域名系统解析器(DNS Resolver)的配置文件路径
"HostnamePath": "/var/lib/docker/containers/572219d3a0ca25a37623a1113f3c8faa6b48d3ab42ae668eac64fcb39cb4dd84/hostname", #当前容器所在的位置
"HostsPath": "/var/lib/docker/containers/572219d3a0ca25a37623a1113f3c8faa6b48d3ab42ae668eac64fcb39cb4dd84/hosts", #容器host文件(域名、IP配置文件)路径
"LogPath": "/var/lib/docker/containers/572219d3a0ca25a37623a1113f3c8faa6b48d3ab42ae668eac64fcb39cb4dd84/572219d3a0ca25a37623a1113f3c8faa6b48d3ab42ae668eac64fcb39cb4dd84-json.log",#容器运行日志文件路径
"Name": "/mysql9", #镜像名称
"RestartCount": 0, #重启个数
"Driver": "overlay2", #存储驱动,联合文件系统
"Platform": "linux", # 运行平台
"MountLabel": "",#挂载标签
"ProcessLabel": "",#进程标签
"AppArmorProfile": "", #Linux内核中的强制访问控制系统配置文件
"ExecIDs": null, #当前容器正在执行 exec的 ID,多个用数组展示
#主机配置
"HostConfig": {



#容器宿主目录绑定
"Binds": [
"/home/mysql8/conf/my.cnf:/etc/mysql/my.cnf",
"/home/mysql8/logs:/logs",
"/home/mysql8/data:/var/lib/mysql",
"/etc/localtime:/etc/localtime"
],
"ContainerIDFile": "", #???
#日志配置
"LogConfig": {



"Type": "json-file", #文件类型 json
"Config": {}
},
"NetworkMode": "default", #网络模式
#端口绑定信息
"PortBindings": {



"3306/tcp": [
{



"HostIp": "",
"HostPort": "3306"
}
]
},
#重启策略
"RestartPolicy": {



"Name": "unless-stopped",#自动重启类似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": true,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": [
"label=disable"
],
"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": null,
"ReadonlyPaths": null
},
#镜像管理驱动
"GraphDriver": {



#联合系统分层信息
"Data": {



#镜像层,目录或者文件是只读的
"LowerDir": "/var/lib/docker/overlay2/77f1db351358d953cb1fe55a79e84597d3cbc3844c2dd249a2acdfa15e402627-init/diff:/var/lib/docker/overlay2/b261e67d747a7a769d143f6d4bc9492684b17680256cdf5962f8145acb6b3dab/diff:/var/lib/docker/overlay2/e88c8d60eec4dee423f121636d8b7a560fe2b4739c6c2361d90e290799989120/diff:/var/lib/docker/overlay2/d8f81e30c57461476828fa01d7faad6cc96f893e55684fabf02bf804f76ca2e8/diff:/var/lib/docker/overlay2/b04b2325906657684ef7914d1834a0e510fc7065c78287ce066b0dd5667273c3/diff:/var/lib/docker/overlay2/f09dec6179a52989205fd2931b31996515e06b8048b139f7cc87982df2f497ad/diff:/var/lib/docker/overlay2/c0eab9ee7da29584d4583dd66199346582f1036f69f9989b7da5f8e72f0fa992/diff:/var/lib/docker/overlay2/2a28cd4140717faa03275c600bae785a8a4b0131337bf04267e000f8569aa0f7/diff:/var/lib/docker/overlay2/733a014a49863d79ffb0d86655d8e3b3ceb4a515266e50c09b6cf02d8f81c9c3/diff:/var/lib/docker/overlay2/5da96f62c2672a8590cb920cf541bc3ac636f1aca7babb540d49316c72e7d74a/diff:/var/lib/docker/overlay2/cdf557bd933d8f3809eb2a4b493f376d81e64ee14d0adbd8a74b57d071f63fd6/diff:/var/lib/docker/overlay2/80e0b0ba180d6736e659f56192c214c95d433e59f0aa6d79bfe66d52fb3c7b73/diff:/var/lib/docker/overlay2/4935d32e3ec461a85af88a19fef5872312b4c43a5adf43848b1f3e25353b7ac8/diff",
#容器的挂载点
"MergedDir": "/var/lib/docker/overlay2/77f1db351358d953cb1fe55a79e84597d3cbc3844c2dd249a2acdfa15e402627/merged",
#读写层,在启动一个容器时候会进行创建,所有的对容器数据更改都发生在这里层,upperdir是可读可写的
"UpperDir": "/var/lib/docker/overlay2/77f1db351358d953cb1fe55a79e84597d3cbc3844c2dd249a2acdfa15e402627/diff",
#工作目录
"WorkDir": "/var/lib/docker/overlay2/77f1db351358d953cb1fe55a79e84597d3cbc3844c2dd249a2acdfa15e402627/work"
},
"Name": "overlay2"
},
#挂载配置
"Mounts": [
{



"Type": "bind", #类型
"Source": "/home/mysql8/logs", #来源目录
"Destination": "/logs", #容器目录
"Mode": "", #模式
"RW": true, #读写权限
"Propagation": "rprivate"
#挂载目录实时更新模式 shared、slave、private、rshared、rslave、rprivate
},
{



"Type": "bind",
"Source": "/home/mysql8/data",
"Destination": "/var/lib/mysql",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{



"Type": "bind",
"Source": "/etc/localtime",
"Destination": "/etc/localtime",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{



"Type": "bind",
"Source": "/home/mysql8/conf/my.cnf",
"Destination": "/etc/mysql/my.cnf",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {



"Hostname": "572219d3a0ca", #容器缩写id
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
#暴露端口
"ExposedPorts": {



"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
#环境变量配置
"Env": [
"MYSQL_ROOT_PASSWORD=431557313",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.12",
"MYSQL_MAJOR=8.0",
"MYSQL_VERSION=8.0.27-1debian10"
],
#设置容器的默认执行的命令,不可以追加命令
"Cmd": [
"mysqld"
],
#镜像名 服务名+tag版本
"Image": "mysql:8.0.27",
"Volumes": {



"/var/lib/mysql": {}
},
#工作目录
"WorkingDir": "",
#设置容器的默认执行的命令,可以追加命令
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,#Dockerfile文件构建
"Labels": {}
},
#网络设置
"NetworkSettings": {



"Bridge": "", #网桥
#沙箱id
"SandboxID": "9d8795184ee28e903bb503b42519d5f56a622977f49e4255e771dfcb1c8bdaf3",
"HairpinMode": false, #是否开启发卡模式
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
#端口配置
"Ports": {



"3306/tcp": [
{



"HostIp": "0.0.0.0",
"HostPort": "3306"
},
{



"HostIp": "::", #外网访问
"HostPort": "3306" #暴力端口
}
],
"33060/tcp": null
},
"SandboxKey": "/var/run/docker/netns/9d8795184ee2", #沙盒密钥路径
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "826898658eec96e305763ce63e6505c4c0e5d152872bf8ae517f73371a8d015e",
"Gateway": "172.17.0.1", #网关地址
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03", #MAC地址
"Networks": {



"bridge": {



"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "376cfaed3501614c09972655643d3d974e434548773d140c0040d9c268294e51",
"EndpointID": "826898658eec96e305763ce63e6505c4c0e5d152872bf8ae517f73371a8d015e",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
}
}
}
}
]

标签:容器,lib,overlay2,详解,var,Docker,null,docker
From: https://blog.51cto.com/itShareArea/5786173

相关文章

  • 容器是否能代替数组
    在.net中,很多开发者都喜欢使用List来代替数组进行使用。容器不仅封装了数组几乎所有的基本操作,而且还可以动态扩容,在开发过程中十分的方便。以下的场景更加建议使用数组:容器......
  • docker 下安装redis
    1、查看redis镜像dockersearchredis2、拉取redis镜像dockerpullredisdockerpullredis:XX//拉取制定版本,如:dockerpullredis:3.2dockerim......
  • centos8 下docker安装mysql
    1、安装dockerhttps://www.cnblogs.com/bk-your/p/16816372.html//安装docker地址2、docker拉取5.7版本的mysqldockerpullmysql:5.7//拉取镜像3、查看拉......
  • docker compose
    (一)dockercompose(1)dockercompose:①概述:1、单机容器编排工具2、dockercompse+docker、swarm实现集群管理3、docker三剑客:dockermachine{管理虚拟机}、dockercompse{容器编排......
  • docker网络
    docker启动后,会产生一个名为docker0的虚拟网桥常用基本命令查看帮助信息[root@docker~]#dockernetwork--help查看网络dockernetworkls查看网络源数据......
  • 什么是分布式,史上最全详解!​
    转自:https://blog.csdn.net/androidstarjack/article/details/118347050  集群与分布式区别集群:复制模式,每台机器做一样的事。分布式:两台机器分工合作,每台机器做的......
  • SpringBoot微服务打包Docker镜像
    1.构建sprintboot项目2.打包应用3.编写dockerfileidea下载docker插件(可以高亮)4.构建镜像先把之前镜像都移除dockerrm-f$(dockerps-qa)在Linuxhome目......
  • TCP协议详解一
    TCP协议的报文格式传输层TCP协议提供了一种面向连接的、可靠的字节流服务,其数据帧格式,大致如下图所示: 图:传输层TCP协议的数据帧格式 一个传输层TCP协议的数据帧,大致......
  • docker删除镜像
    docker要删除镜像,先要删除依赖它的容器1.删除容器dockerps#查看正在运行的容器dockerps-a#查看所有容器dockerrmcontainer_id#删除容器2.删除镜像dockeri......
  • windows安装docker
    安装DockerDesktopwindows10及以上版本可以直接安装DockerDesktop(官方推荐)。根据提示下载linuxkernelupdate,双击安装即可。更换中国源{"registry-mirrors":[......