京寵展信息指南
1959
2022-05-29
前言
一 slopeo簡(jiǎn)介
1.1 簡(jiǎn)介
skopeo 是一個(gè)命令行工具,用于對(duì)容器鏡像和鏡像庫執(zhí)行各種操作,支持使用 OCI 鏡像與原始的 Docker v2 鏡像。可對(duì)容器鏡像和容器存儲(chǔ)進(jìn)行操作。 在沒有dockerd的環(huán)境下,使用 skopeo 操作鏡像是非常方便的。Skopeo 能夠在容器注冊(cè)表上檢查存儲(chǔ)庫并獲取圖片層。Inspect 命令獲取存儲(chǔ)庫的清單,它能夠向您顯示關(guān)于整個(gè)存儲(chǔ)庫或標(biāo)記的類似 docker inspect 的 json 輸出。與 docker inspect 不同,這個(gè)工具可以幫助您在拉取存儲(chǔ)庫或標(biāo)記之前(使用磁盤空間)收集有用的信息。Inspect 命令可以顯示給定存儲(chǔ)庫可用的標(biāo)記、圖像的標(biāo)簽、圖像的創(chuàng)建日期和操作系統(tǒng)等等。
1.2 特性
skopeo 使用 API V2 注冊(cè)表,例如 Docker 注冊(cè)表、Atomic 注冊(cè)表、私有注冊(cè)表、本地目錄和本地 OCI 布局目錄。skopeo
不需要運(yùn)行守護(hù)進(jìn)程,它可以執(zhí)行的操作包括:
通過各種存儲(chǔ)機(jī)制復(fù)制鏡像,例如,可以在不需要特權(quán)的情況下將鏡像從一個(gè)注冊(cè)表復(fù)制到另一個(gè)注冊(cè)表
檢測(cè)遠(yuǎn)程鏡像并查看其屬性,包括其圖層,無需將鏡像拉到本地
從鏡像庫中刪除鏡像
當(dāng)存儲(chǔ)庫需要時(shí),skopeo 可以傳遞適當(dāng)?shù)膽{據(jù)和證書進(jìn)行身份驗(yàn)證
二 安裝
RHEL/CentOS ≤ 7.x
sudo yum -y install skopeo
macOS
brew install skopeo
詳細(xì)可參考:https://github.com/containers/skopeo/blob/main/install.md
三 使用
$ skopeo -h Various operations with container images and container image registries Usage: skopeo [flags] skopeo [command] Available Commands: copy Copy an IMAGE-NAME from one location to another delete Delete image IMAGE-NAME help Help about any command inspect Inspect image IMAGE-NAME list-tags List tags in the transport/repository specified by the REPOSITORY-NAME login Login to a container registry logout Logout of a container registry manifest-digest Compute a manifest digest of a file standalone-sign Create a signature using local files standalone-verify Verify a signature using local files sync Synchronize one or more images from one location to another Flags: --command-timeout duration timeout for the command execution --debug enable debug output -h, --help help for skopeo --insecure-policy run the tool without any policy check --override-arch ARCH use ARCH instead of the architecture of the machine for choosing images --override-os OS use OS instead of the running OS for choosing images --override-variant VARIANT use VARIANT instead of the running architecture variant for choosing images --policy string Path to a trust policy file --registries.d DIR use registry configuration files in DIR (e.g. for container signature storage) --tmpdir string directory used to store temporary files -v, --version Version for Skopeo Use "skopeo [command] --help" for more information about a command.
3.1 檢查存儲(chǔ)庫
顯示鏡像屬性
遠(yuǎn)程倉(cāng)庫
docker://: 是使用 Docker Registry HTTP API V2 進(jìn)行連接遠(yuǎn)端
docker.io: 遠(yuǎn)程倉(cāng)庫
fedora:latest: 鏡像名稱及tag
$ skopeo inspect docker://docker.io/fedora:latest
利用jq查看指定的信息。
$ skopeo inspect docker://registry.fedoraproject.org/fedora:latest | jq .Digest
查看本地鏡像
$ skopeo inspect docker-daemon:mysql:8.0.19 { "Name": "docker.io/library/mysql", "Digest": "sha256:8084d869573a2e1be9d49d1b8dea49b54fc43301a3ead4b8124eedb809cf3c3f", "RepoTags": [], "Created": "2020-04-23T04:14:55.648457026Z", "DockerVersion": "18.09.7", "Labels": null, "Architecture": "amd64", "Os": "linux", "Layers": [ "sha256:c2adabaecedbda0af72b153c6499a0555f3a769d52370469d8f6bd6328af9b13", "sha256:49003fe88142d189c33a6e52b97081c8d62b67e0d04e9e7421ca6a2495b0d766", "sha256:8d3b3830445d713c580008a547de7398ab721a083fda915526ce2cc557c4f40a", "sha256:49baacc63c3bb5a7ab5077ef6458d6e246710195d7794cb704940f3a40495c23", "sha256:24bd91e7be374167e51e37faa31e7ce143921afb0b968415c749625319386fdb", "sha256:d84f8cf1dc236ea2ddbc0393b0c33099bedb20fffbe68bdf170d2df161a1ca16", "sha256:ace74cb61ec0a3fd2847dc3a0b8b0cad349c95ce02732982e258fc1a337d073f", "sha256:ba6f785586f5ff477e87528a5d2c8d0215e22f5b9ac3a8f4b19a033cad7aa832", "sha256:c861c8d6e01539cc5b27fe773aca63958bc361391f6a980ece5322fd8dbca296", "sha256:1ac7b6bb690abc8073c2193635afb06b8494d2d0024dc08310b296975f92bb61", "sha256:b8e742ca24b882430bf4a6075aa97a8c1e8809f6e59d462cba05bec49d817ff3", "sha256:7fc1a766ce1413db3d5fceb7256c1e54639386673c24eadaf69b429b07eb9223" ], "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GOSU_VERSION=1.12", "MYSQL_MAJOR=8.0", "MYSQL_VERSION=8.0.19-1debian10" ] }
3.2 拷貝鏡像
在不使用 docker 的情況下從遠(yuǎn)端下載鏡像
# 下載遠(yuǎn)程鏡像到/tmp/下,命名為nginx.tar skopeo --insecure-policy copy docker://nginx:1.17.6 docker-archive:/tmp/nginx.tar # 將本地tar鏡像文件導(dǎo)入到docker中 skopeo copy docker-archive:/tmp/nginx.tar docker-daemon:nginx:latest
3.3 刪除鏡像
skopeo delete docker://localhost:5000/nginx:latest
3.4 注冊(cè)表認(rèn)證
認(rèn)證文件默認(rèn)存放在$HOME/.docker/config.json
文件內(nèi)容
{ "auths": { "myregistrydomain.com:5000": { "auth": "dGVzdHVzZXI6dGVzdHBhc3N3b3Jk", "email": "stuf@ex.cm" } } }
參考鏈接
https://www.redhat.com/zh/blog/skopeo-copy-rescue
https://github.com/containers/skopeo
https://lework.github.io/2020/04/13/skopeo/
Docker 鏡像服務(wù)
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。