How to manage Linux container images and repositories using skopeo

Here in this article we will see how we can use Skopeo to manage remote repository container images. Skopeo is an open source community tool and it helps with operations like inspecting the remote image, copying images between repositories and also deleting the remote repository images. If you are interested in watching video. You can watch the below video with the same steps in this article.
Test Environment
Fedora 32 installed
What is Skopeo
Skopeo is opensource community tool provided to manage the container images and repositories hosted remotely. They do not need any daemon to perform their operations. Skopeo works with OCI compliant images and also with Docker v2 images. Skopeo can be useful in performing various operations like copying container images between different registries, Inspecting a remote image without pulling it and deleting images from remote repositories.
If you are interested in watching the video. Here is the YouTube video on the same step by step procedure outlined below.
Procedure
Step1: Install skopeo for container images and repository management
As a first step we need to have the skopeo tool installed on our system so we can use it to manage container images and remote repositories. It can be installed as below and as you can see there no dependencies that are installed with this tool.
[root@fed32 ~]# sudo dnf -y install skopeo
[sudo] password for admin:
Last metadata expiration check: 0:10:22 ago on Tue 17 Nov 2020 09:36:05 PM IST.
Dependencies resolved.
=======================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================
Installing:
skopeo x86_64 1:1.2.0-2.fc32 updates 6.9 M
...
Installed:
skopeo-1:1.2.0-2.fc32.x86_64
Complete!
Step2: Connect skopeo to remote repository by authenticating using credentials
In order to manage the remote repository we first need to connect to the repository and passing the credentials as shown below.
[root@fed32 ~]# skopeo login docker.io
Username: novicejava1
Password:
Login Succeeded!
Step3: List tags available on the remote repository
Once we are connected we list the images and their respective tags which are available as shown below. As an example i have connected to my remote repositories for this step.
[root@fed32 ~]# skopeo list-tags docker://docker.io/novicejava1/apacheweb
{
"Repository": "docker.io/novicejava1/apacheweb",
"Tags": [
"latest"
]
}
[root@fed32 ~]# skopeo list-tags docker://docker.io/novicejava1/hello
{
"Repository": "docker.io/novicejava1/hello",
"Tags": [
"1.0"
]
}
Step4: Inspect the remote repository image
We can inspect the remote image using inspect and get the details of the images as shown below.
[root@fed32 ~]# skopeo inspect docker://docker.io/novicejava1/apacheweb
{
"Name": "docker.io/novicejava1/apacheweb",
"Digest": "sha256:b196bb021718076ccb3ed34c3c37be95da05a00469218bc250e302cffeb9df3c",
"RepoTags": [
"latest"
],
"Created": "2020-10-26T11:01:28.902764612Z",
"DockerVersion": "19.03.8",
"Labels": {
"maintainer": "Clement Verna u003ccverna@fedoraproject.orgu003e"
},
"Architecture": "amd64",
"Os": "linux",
"Layers": [
"sha256:8447a86791f76e02fdd4722a7cf61aa10dbfb58bdac0c028c80158754779bb62",
"sha256:ecd341485a45807a15fd6b40d892a6cfba41f35d14cd26da70d13529908270b7",
"sha256:7e2c4ed816ec9b8e089e53263e5fe4d448e002d44e42374ac81671c261f64c73"
],
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DISTTAG=f32container",
"FGC=f32",
"FBR=f32"
]
}
Step5: Copy remote image in the same repository with different tag
Skopeo also helps in copying the images from one remote repository to another. Here i am showing how we can copy an image in the same repository with a different tag.
[root@fed32 ~]# skopeo copy docker://docker.io/novicejava1/hello:1.0 docker://docker.io/novicejava1/hello:2.0
Getting image source signatures
Copying blob 22cef3226003 skipped: already exists
Copying blob ed03608500cb skipped: already exists
Copying blob f891121bf6d1 [--------------------------------------] 0.0b / 0.0b
Copying config b6611cf6b4 [--------------------------------------] 0.0b / 1.2KiB
Writing manifest to image destination
Storing signatures
Hope you enjoyed reading this article. Thank you..
Leave a Reply
You must be logged in to post a comment.