[banner@stapp03 ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 26828d185a8f 5 seconds ago 125MB
ubuntu latest 174c8c134b2a 3 weeks ago 77.8MB
有 2 个图像 - 我想在 cli 中输入命令并获取最新的图像 ID(第一行)并将其用于其他后续命令。 不能用鼠标点击选择图片id,怎么办?
我们可以通过
docker
定义每个--format <fmt-string>
命令的输出格式。详情请参阅相应docs.docker.com
页面。
如果我们想要所有图像的 id,我们可以运行
$ docker image ls --format {{.Id}}
如果我们只想要 ubuntu 映像的 ID,我们可以运行
$ docker image ls ubuntu --format {{.Id}}