docker inspect : 获取容器/镜像的元数据。
语法
docker inspect [options] name|id [name|id...]
options说明:
-
-f :指定返回值的模板文件。
-
-s :显示总的文件大小。
-
--type :为指定类型返回json。
实例
获取镜像mysql:5.6的元信息。
coonote@coonote:~$ docker inspect mysql:5.6
[
{
"id": "sha256:2c0964ec182ae9a045f866bbc2553087f6e42bfc16074a74fb820af235f070ec",
"repotags": [
"mysql:5.6"
],
"repodigests": [],
"parent": "",
"comment": "",
"created": "2016-05-24t04:01:41.168371815z",
"container": "e0924bc460ff97787f34610115e9363e6363b30b8efa406e28eb495ab199ca54",
"containerconfig": {
"hostname": "b0cf605c7757",
"domainname": "",
"user": "",
"attachstdin": false,
"attachstdout": false,
"attachstderr": false,
"exposedports": {
"3306/tcp": {}
},
...
获取正在运行的容器mymysql的 ip。
coonote@coonote:~$ docker inspect --format='{{range .networksettings.networks}}{{.ipaddress}}{{end}}' mymysql
172.17.0.3