Get access to AWS ECR from the container using the installed amazon-ecr-credential-helper
313
A full "docker-in-docker" dind image of the base docker:stable-dind with the
docker-credentials-helpers implementation of AWS to push
images to the AWS Docker registry ECR
You can find the sources of this image on GitHub and GitLab.
The property in the config.json let Docker search for the amazon-ecr-credential-helper in specific paths, when execute docker push/pull.
In this image it lays in /usr/bin.
Docker will automatically execute amazon-ecr-credential-helper with the environment variables 'AWS_ACCESS_KEY_ID' & 'AWS_SECRET_ACCESS_KEY'
to get a token and will authorize using this token while pushing/pulling an image.
The built image is pushed to the Docker hub
You can use it or build your own image with the Dockerfile
You need rights to create a new AWS user.
As said before, environment variables have to been configured:
<account_id>.dkr.ecr.<region>.amazonaws.com/<service_name>This is an example of a ready to go Docker build entry in the .gitlab-ci.yml for building a Docker image and pushing it to an existing ECR:
docker-build-master:
image: bausparkadse/aws-ecr-gitlab:3
stage: docker
services:
- docker:dind
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE_AWS:$CI_COMMIT_SHORT_SHA" .
- docker push "$CI_REGISTRY_IMAGE_AWS:$CI_COMMIT_SHORT_SHA"
only:
- master
Content type
Image
Digest
Size
74 MB
Last updated
over 6 years ago
docker pull bausparkadse/aws-ecr-gitlab:3