In the configuration where I saved the Docker image in Amazon ECR and deployed it to Fargate with AWS CodePipeline, the deployment failed. There seems to be something wrong with the container, so I want to check the container. In that situation, I dropped the Docker image from ECR and wanted to check it, but I always forget how to do it, so I will leave it as a memorandum.
$ docker pull your-aws-account-id.dkr.ecr.ap-northeast-1.amazonaws.com/xxx/yyy/zzz:latest
When I executed the above command, an authentication error occurred. (Select the URL of the image by selecting ECR in the AWS console)
https://docs.aws.amazon.com/ja_jp/AmazonECR/latest/userguide/Registries.html#registry_auth If you check here, it seems that registry authentication is required.
$ aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin your-aws-account-id.dkr.ecr.ap-northeast-1.amazonaws.com
Log in with this. Note that there was no get-login-password in aws cli v1. It may be necessary to set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN in the environment variables in advance.
If this succeeds, re-execute the docker pull and it will succeed.
$ docker images
First, check that the image has been added with the above command.
$ docker run -it your-aws-account-id.dkr.ecr.ap-northeast-1.amazonaws.com/xxx/yyy/zzz:latest /bin/bash
Finally, enter / bin/bash
to put it in the container with bash. Feel free to do the rest.
Recommended Posts