Last active
January 3, 2023 16:16
-
-
Save bbuechler/74abf62c58bb41d940495a0380d3206c to your computer and use it in GitHub Desktop.
Quick and easy way to patch an ECR container without rebuilding
This file contains hidden or 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
ECR_REG=12345678910.dkr.ecr.us-west-2.amazonaws.com | |
ECR_REPO=my_app | |
ECR_TAG=tag_name | |
RUN_NAME=${ECR_REPO}_new | |
# login to ECR | |
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin $ECR_REG | |
# Start container | |
docker run --detach --name $RUN_NAME $ECR_REG/$ECR_REPO:$ECR_TAG tail -f /dev/null | |
# Copy files into running container | |
docker cp /local/path/to/file.sh ${RUN_NAME}:/container/path/file.sh | |
# Retag | |
docker commit $RUN_NAME ${ECR_REG}/${ECR_REPO}:${ECR_TAG} | |
# Push | |
docker push ${ECR_REG}/${ECR_REPO}:${ECR_TAG} | |
# continue cycling by repeating... | |
# $ docker cp ... | |
# $ docker commit ... | |
# $ docker push ... | |
# | |
# Docker push will output a sha256: | |
# $ docker push ... | |
# The push refers to repository [12345678910.dkr.ecr.us-west-2.amazonaws.com/my_app] | |
# 93aaaaaaaa49: Pushed | |
# bdbbbbbbbb1a: Layer already exists | |
# 0bcccccccc56: Layer already exists | |
# tag_name: digest: sha256:44dddd....dddd16b size: 4490 | |
# | |
# On the remote system, be clear the active layer and pull, or specify new sha: | |
# $ docker run -it 12345678910.dkr.ecr.us-west-2.amazonaws.com/my_app@sha256:44dddd....dddd16b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Totally using this. Thanks Brian!