Docker查看鏡像詳情的多種常用方法介紹
查看 Docker 鏡像詳情的幾種常用方法:
1.查看鏡像基本信息
# 查看所有鏡像列表
docker images
# 詳細格式查看
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}"
# 按特定字段排序
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" | sort

2.查看鏡像詳細信息
# 查看鏡像的完整詳細信息
docker image inspect <鏡像名或ID>
# 查看特定信息(JSON格式)
docker image inspect <鏡像名> --format='{{json .}}'
# 提取特定字段
docker image inspect <鏡像名> --format='{{.Id}}'
docker image inspect <鏡像名> --format='{{.Created}}'
docker image inspect <鏡像名> --format='{{.RepoTags}}'
docker image inspect <鏡像名> --format='{{.Size}}'
docker image inspect <鏡像名> --format='{{.Architecture}}'
docker image inspect <鏡像名> --format='{{.Os}}'
3.查看鏡像分層歷史
# 查看鏡像的構(gòu)建歷史 docker history <鏡像名> # 顯示完整信息(包括創(chuàng)建命令) docker history --no-trunc <鏡像名> # 人類可讀的格式 docker history --human=true <鏡像名>
4.查看鏡像內(nèi)容
# 查看鏡像中的文件系統(tǒng) docker run -it <鏡像名> ls -la / # 或者進入鏡像的shell(如果鏡像有bash/sh) docker run -it <鏡像名> /bin/bash
5.使用 dive 工具(更詳細的分析)
# 安裝 dive # Ubuntu/Debian wget https://github.com/wagoodman/dive/releases/download/v0.11.0/dive_0.11.0_linux_amd64.deb sudo apt install ./dive_0.11.0_linux_amd64.deb # 使用 dive 分析鏡像 dive <鏡像名>
6.查看鏡像的元數(shù)據(jù)
# 查看 Dockerfile 中的標簽
docker image inspect <鏡像名> --format='{{json .Config.Labels}}'
# 查看環(huán)境變量
docker image inspect <鏡像名> --format='{{json .Config.Env}}'
# 查看入口點和命令
docker image inspect <鏡像名> --format='{{json .Config.Entrypoint}}'
docker image inspect <鏡像名> --format='{{json .Config.Cmd}}'
# 查看工作目錄
docker image inspect <鏡像名> --format='{{.Config.WorkingDir}}'
# 查看暴露的端口
docker image inspect <鏡像名> --format='{{json .Config.ExposedPorts}}'
7.實用查詢示例
# 查看鏡像架構(gòu)(重要?。?
docker image inspect ubuntu:latest --format='{{.Architecture}}'
# 查看鏡像創(chuàng)建時間
docker image inspect ubuntu:latest --format='{{.Created}}'
# 查看鏡像大小
docker image inspect ubuntu:latest --format='{{.Size}}' | numfmt --to=iec
# 查看鏡像摘要(digest)
docker image inspect ubuntu:latest --format='{{index .RepoDigests 0}}'
# 查看所有信息(格式化輸出)
docker image inspect ubuntu:latest | python3 -m json.tool
# 或者使用 jq(需要安裝)
docker image inspect ubuntu:latest | jq '.[0]'
8.組合查詢示例
# 顯示鏡像摘要信息
echo "=== 鏡像基本信息 ==="
docker image inspect ubuntu:latest --format='鏡像ID: {{.Id}}
架構(gòu): {{.Architecture}}
創(chuàng)建時間: {{.Created}}
大小: {{.Size}} 字節(jié)
標簽: {{.RepoTags}}
摘要: {{index .RepoDigests 0}}'
# 查看鏡像的層信息
docker image inspect ubuntu:latest --format='{{range .RootFS.Layers}}{{.}}
{{end}}'
9.查看遠程倉庫中的鏡像
# 使用 skopeo(需要安裝) skopeo inspect docker://ubuntu:latest # 使用 crane(Google的工具) crane manifest ubuntu:latest
10.GUI 工具(可選)
- Portainer:Web 界面管理 Docker
- Lazydocker:終端 UI
- Docker Desktop:桌面客戶端
最常用的組合命令:
# 快速查看鏡像核心信息
docker images && echo "---" && docker image inspect <鏡像名> --format='架構(gòu): {{.Architecture}}, 大小: {{.Size}}, 創(chuàng)建于: {{.Created}}'
到此這篇關(guān)于Docker查看鏡像詳情的多種常用方法介紹的文章就介紹到這了,更多相關(guān)Docker查看鏡像內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
docker部署mysql和nginx服務(wù)的示例詳解
這篇文章主要為大家詳細介紹了docker部署mysql和nginx服務(wù)的相關(guān)知識,文中的示例代碼簡潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-04-04
Docker提示permission?denied錯誤的解決方案
這篇文章主要給大家介紹了關(guān)于Docker提示permission?denied錯誤的解決方案,出現(xiàn)這個問題是因為宿主機的當(dāng)前運行用戶和docker容器里面的運行用戶不一致導(dǎo)致訪問權(quán)限問題,需要的朋友可以參考下2023-08-08
寶塔創(chuàng)建Docker容器配置nginx的實現(xiàn)步驟
本文主要介紹了寶塔創(chuàng)建Docker容器配置nginx的實現(xiàn)步驟,文中通過圖文介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-06-06
docker通過Dockerfile構(gòu)建mysql鏡像的方法
這篇文章主要介紹了docker通過Dockerfile構(gòu)建mysql鏡像,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05
如何將gitbub下載的docker-compose項目運行在docker
這篇文章主要介紹了如何將gitbub下載的docker-compose項目運行在docker問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05
如何在 Ubuntu 下通過 Docker 部署 Caddy 
本文介紹了如何在Ubuntu系統(tǒng)下通過Docker部署Caddy服務(wù)器,首先安裝Docker,然后啟動Docker服務(wù)并設(shè)置為開機自啟,接著拉取Caddy鏡像,并創(chuàng)建一個Caddyfile配置文件,使用命令運行Caddy容器,并將本地的Caddyfile掛載到容器內(nèi),感興趣的朋友跟隨小編一起看看吧2025-03-03
Docker安裝部署分布式數(shù)據(jù)庫?OceanBase的詳細過程
這篇文章主要介紹了Docker安裝部署分布式數(shù)據(jù)庫?OceanBase,快速的體驗 OceanBase 的自動化部署過程,及了解 OceanBase 集群安裝成功后的目錄特點和使用方法,需要的朋友可以參考下2022-06-06

