Created
July 27, 2022 19:52
-
-
Save johnstanfield/52e9274237648894221e4dffc132bdd3 to your computer and use it in GitHub Desktop.
Edit a Docker image and push it to ECR. Sometimes you just want to pull a container image, edit a file, and push it back, outside of source control and CI/CD. This is how.
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
# note: get your AWS credentials however you usually do that (e.g. aws configure or set the env vars) | |
REPO_URL=accountid.dkr.ecr.region.amazonaws.com/repo-name | |
EXISTING_TAG=version1 | |
NEW_TAG=version1-hotfix | |
# get everything ready | |
mkdir -p ~/slipstream | |
cd ~/slipstream | |
`aws ecr get-login --no-include-email` | |
# pull the image from ECR | |
docker pull $REPO_URL:$EXISTING_TAG | |
# copy the desired file(s) from the image to the local dir | |
imageid=`docker create $REPO_URL:$EXISTING_TAG` | |
docker cp $imageid:/home/your/app/the/file.txt . | |
# edit the file and put it back into the image | |
vi file.txt | |
docker cp file.txt $imageid:/home/your/app/the/file.txt | |
# now tag the edited image | |
docker commit $imageid $REPO_URL:$NEW_TAG | |
# double-check that the change is in the new image | |
docker run -it $REPO_URL:$NEW_TAG cat /home/your/app/the/file.txt | |
# push it back to ECR | |
docker push $REPO_URL:$NEW_TAG | |
# now redeploy your app with the new tag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment