>docker image pull ubuntu
// tagを設定しなければ、最新のタグのものをインストールする。
Using default tag: latest
latest: Pulling from library/ubuntu
5a7813e071bf: Download complete
Digest: sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09856619a782
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
>docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 72297848456d 12 days ago 117MB
hello-world latest d715f14f9eca 2 weeks ago 20.4kB
・・・
// ubuntuをインストールされていることを確認出来た。
// repository: イメージ名
// tag: イメージのバージョン
>docker image pull ubuntu:20.04
// タグ指定している。
20.04: Pulling from library/ubuntu
d9802f032d67: Download complete
Digest: sha256:8e5c4f0285ecbb4ead070431d29b576a530d3166df73ec44affc1cd27555141b
Status: Downloaded newer image for ubuntu:20.04
docker.io/library/ubuntu:20.04
// 実行すると、今度はubuntu:20.04がダウンロードされる。
>docker image ls
// イメージがダウンロード出来ているのか確認する。
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 72297848456d 12 days ago 117MB
ubuntu 20.04 8e5c4f0285ec 4 months ago 109MB
// tagが異なっていることが確認できた。
>docker image rm ubuntu
Untagged: ubuntu:latest
Deleted: sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09856619a782
// tagを指定していないため、ubuntu:latestが削除された。
>docker image ls
// イメージが削除されているか確認する。
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 20.04 8e5c4f0285ec 4 months ago 109MB
// ubuntu:20.04のみになっている事がわかる。
>docker image rm 8e5c4f0285ec
Untagged: ubuntu:20.04
Deleted: sha256:8e5c4f0285ecbb4ead070431d29b576a530d3166df73ec44affc1cd27555141b
>docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
// イメージが削除されたことを確認。