Thanks to Skopeo, we can easily copy container images from one registry to another. In this article, we’ll copy images from docker.io to quay.io, a container registry that has a lot of features that docker.io doesn’t provide. The first feature that I really like is the ability to list and manage image vulnerabilities and other security information. The second is the ability to manage image manifests.
I wrote a small script that one can use to automate image copying. Before running the script, do the following:
- Get an OAuth token from https://quay.io/organization/[your-org]?tab=applications.
- Change the token, namespace, containers, and tag (if needed).
- If your docker.io registry requires authentication, run
podman login docker.io( the–src-credsoption can also be used with Skopeo). - Authenticate against your quay.io registry with
podman login quay.io(the–dest-credsoption can also be used with Skopeo).
Here is the script:
#!/bin/sh
set -ex
# get OAuth token from https://quay.io/organization/[your-org]?tab=applications
token='secrete'
namespace=yourorg
containers='app1 app2'
tag=latest
retry() {
local -r -i max_attempts="$1"; shift
local -r cmd="$@"
local -i attempt_num=1
until $cmd
do
if ((attempt_num==max_attempts))
then
echo "Attempt $attempt_num failed and there are no more attempts left!"
return 1
else
echo "Attempt $attempt_num failed! Trying again in $attempt_num seconds..."
sleep $((attempt_num++))
fi
done
}
for container in $containers; do
# create empty public repo first otherwise skopeo will create the image as private
curl -X POST https://quay.io/api/v1/repository \
-d '{"namespace":"'$namespace'","repository":"'$container'","description":"Container image '$container'","visibility":"public"}' \
-H 'Authorization: Bearer '$token'' -H "Content-Type: application/json"
# workaround if quay.io returns 500 error, likely due to an internal bug when using skopeo against docker.io
copy="skopeo copy docker://docker.io/$namespace/$container:$tag docker://quay.io/$namespace/$container:$tag"
retry 5 $copy
done
As you can see, there are two unusual things in this script. First, the curl command creates an empty public image; otherwise, quay.io would create a private image by default when copying the image with Skopeo. As far as I know, there is no option in quay.io to change the default policy. Of course, you can remove it if you don’t want your image to be public by default.
Second, the retry mechanism works around the 500 error that tells you that the repository already exists when Skopeo provisions a new repository (which sounds specific to how the registry receives authentication from Skopeo vs. Docker CLI).
For more information, check out the quay.io documentation.
Enjoy Skopeo and quay.io!
저자 소개
Emilien has been contributing to OpenStack since 2011 when it was still a young project. He has helped customers have a better experience when deploying, upgrading and operating OpenStack at large scale. His current focus is the integration between OpenShift and OpenStack. He's maintainer of core components including the Cluster API Provider for OpenStack and Gophercloud. Technical and team leader at Red Hat, he's developing leadership skills with passion for teamwork and technical challenges. He loves sharing his knowledge and often give talks to conferences.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래