Skip to main content

5. Skopeo - Moving & Sharing

About 5 minRedHatcrashcourseredhatbuildahpodmanskopeosesearchsemodule

5. Skopeo - Moving & Sharing 관련


Red Hat Container Tools

Intro

In this step, we are going to do a couple of simple exercises with Skopeo to give you a feel for what it can do. Skopeo doesn't need to interact with the local container storage (.local/share/containers), it can move directly between registries, between container engine storage, or even directories.


Remotely Inspecting Images

First, lets start with the use case that kicked off the Skopeo project. Sometimes, it's really convenient to inspect an image remotely before pulling it down to the local cache. This allows us to inspect the meta-data of the image and see if we really want to use it, without synchronizing it to the local image cache:

Input
skopeo inspect docker://registry.fedoraproject.org/fedora

We can easily see the "Architecture" and "Os" meta-data which tells us a lot about the image. We can also see the labels, which are consumed by most container engines, and passed to the runtime to be constructed as environment variables. By comparison, here's how to see this meta-data in a running container:

Input
podman run --name meta-data-container -id registry.fedoraproject.org/fedora bash
podman inspect meta-data-container

Pulling Images

Like, Podman, Skopeo can be used to pull images down into the local container storage:

Input
skopeo copy docker://registry.fedoraproject.org/fedora containers-storage:fedora

But, it can also be used to pull them into a local directory:

Input
skopeo copy docker://registry.fedoraproject.org/fedora dir:$HOME/fedora-skopeo

This has the advantage of not being mapped into our container storage. This can be convenient for security analysis:

ls -alh ~/fedora-skopeo
# total 71M
# drwxr-xr-x. 2 root root  186 Sep 12 08:41 .
# dr-xr-x---. 6 root root  183 Sep 12 08:41 ..
# -rw-r--r--. 1 root root  71M Sep 12 08:41 18ca996a454fc86375a6ea7ad01157a6b39e28c32460d36eb1479d42334e57ad
# -rw-r--r--. 1 root root 1.3K Sep 12 08:41 72c9e456423548988a55fa920bb35c194d568ca1959ffcc7316c02e2f60ea0ff
# -rw-r--r--. 1 root root  429 Sep 12 08:41 manifest.json
# -rw-r--r--. 1 root root   33 Sep 12 08:41 version

The Config and Image Layers are there, but remember we need to rely on a Graph Driveropen in new window in a Container Engineopen in new window to map them into a RootFS.


Moving Between Container Storage (Podman & Docker)

First, let's do a little hack to install Docker CE side by side with Podman on RHEL 8. Don't do this on a production system as this will overwrite the version of runc provided by Red Hat:

yes|sudo rpm -ivh --nodeps --force https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm
# Retrieving https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm
# warning: /var/tmp/rpm-tmp.6uT8NZ: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
# Verifying...                          ################################# [100%]
# Preparing...                          ################################# [100%]
# Updating / installing...
#    1:containerd.io-1.3.7-3.1.el8      ################################# [100%]
sudo yum install -y docker-ce --nobest

Now, enable the Docker CE service:

sudo systemctl enable --now docker
# Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

Now that we have Docker and Podman installed side by side with the Docker daemon running, lets copy an image from Podman to Docker. Since we have the image stored locally in .local/share/containers, it's trivial to copy it to /var/lib/docker using the daemon:

Input
skopeo copy containers-storage:registry.fedoraproject.org/fedora docker-daemon:registry.fedoraproject.org/fedora:latest

Verify that the repository is now in the Docker CE cache:

Input
docker images | grep registry.fedoraproject.org

This can be useful when testing and getting comfortable with other OCI complaint tools like Podman, Buildah, and Skopeo. Sometimes, you aren't quite ready to let go of what you know so having them side by side can be useful. Remember though, this isn't supported because it replaces the runc provided by Red Hat.


Moving Between Container Registries

Finally, lets copy from one registry to another. I have set up a writeable repository under my username (fatherlinux) on quay.io. To do this, you have to use the credentials provided below. Notice, that we use the "--dest-creds" option to authenticate. We can also use the "--source-cred" option to pull from a registry which requires authentication. This tool is very flexible. Designed by engineers, for engineers.

Input
skopeo copy docker://registry.fedoraproject.org/fedora docker://quay.io/fatherlinux/fedora --dest-creds fatherlinux+fedora:5R4YX2LHHVB682OX232TMFSBGFT350IV70SBLDKU46LAFIY6HEGN4OYGJ2SCD4HI

This command just synchronized the fedora repository from the Fedora Registry to Quay.io without ever caching it in the local container storage. Very cool right?

Finally, exit the "rhel" user because we need root for the next lab:

exit

Conclusion

You have a new tool in your tool belt for sharing and moving containers. Hopefully, you find other uses for Skopeo.


이찬희 (MarkiiimarK)
Never Stop Learning.