当前位置:   article > 正文

Docker inspect 命令

docker inspect

docker inspect : 获取容器/镜像的元数据。

语法

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

OPTIONS说明:

  • -f :指定返回值的模板文件。

  • -s :显示总的文件大小。

  • --type :为指定类型返回JSON。

实例

获取镜像mysql:5.6的元信息。

  1. runoob@runoob:~$ docker inspect mysql:5.6
  2. [
  3. {
  4. "Id": "sha256:2c0964ec182ae9a045f866bbc2553087f6e42bfc16074a74fb820af235f070ec",
  5. "RepoTags": [
  6. "mysql:5.6"
  7. ],
  8. "RepoDigests": [],
  9. "Parent": "",
  10. "Comment": "",
  11. "Created": "2016-05-24T04:01:41.168371815Z",
  12. "Container": "e0924bc460ff97787f34610115e9363e6363b30b8efa406e28eb495ab199ca54",
  13. "ContainerConfig": {
  14. "Hostname": "b0cf605c7757",
  15. "Domainname": "",
  16. "User": "",
  17. "AttachStdin": false,
  18. "AttachStdout": false,
  19. "AttachStderr": false,
  20. "ExposedPorts": {
  21. "3306/tcp": {}
  22. },
  23. ...
:~$ 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。

  1. runoob@runoob:~$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mymysql
  2. 172.17.0.3
:~$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mymysql 172.17.0.3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/305560
推荐阅读
相关标签
  

闽ICP备14008679号