Created
February 27, 2020 22:23
-
-
Save mexisme/7ce1a715ad18bcad682bfb469555337b to your computer and use it in GitHub Desktop.
Download an AWS ECR image using Skopeo instead of Docker (e.g. running within a container)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
# set -o pipefile | |
docker_version=${REPO_TAG} | |
docker_image=${REPO_IMAGE} | |
# docker_creds=$(aws ecr get-authorization-token --output json |jq -r '.authorizationData[].authorizationToken' |base64 -d) | |
docker_creds="AWS:$(aws ecr get-login-password)" | |
docker_base=temp | |
docker_inspect=${docker_base}.inspect.json | |
docker_exported=${docker_base}.tgz | |
skopeo inspect --creds "${docker_creds}" docker://"${docker_image}:${docker_version}" |tee "${docker_inspect}" | |
## Download the image from ECR | |
## NOTE: "--additional-tag" is needed because Skopeo won't also import tags from the source image | |
## (https://github.com/containers/skopeo/issues/472) | |
## Since it's a valid Docker archive, "docker load -i ${FILE}" will import it untagged, which will appear | |
## as "<none>" when viewing the images in your local registry. | |
## Remove these if you don't care about it (e.g. using the below "skopeo copy"). | |
skopeo copy \ | |
--src-creds "${docker_creds}" \ | |
--additional-tag "${docker_image}:${docker_version}" --additional-tag "${docker_image}:latest" \ | |
docker://"${docker_image}:${docker_version}" docker-archive:"${docker_exported}" | |
## Copy into the local dockerd | |
## NOTE: This won't apply any tags embedded in the archive, but will tag it as "opa-stuff:latest" | |
# skopeo copy docker-archive:temp.tgz"${docker_exported}" docker-daemon:opa-stuff:latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment