Coder Social home page Coder Social logo

docker-swarm-aws-ecr-auth's Introduction

Docker for AWS swarm auto login to AWS ECR registry

-- Using AWS ECR with a Docker Swarm stack on AWS

When creating a docker swarm stack on AWS, you can want to use the AWS ECR service as your docker images registry.

The problem

The ECR authentication tokens are only valid for 12 hours, so the docker swarm services won't be able to scale on another node after the expire date.

The solution

This docker image renews the ECR token each 4h and update all the services using an ECR image.

Usage as a swarm service (recommended)

docker service create \
    --name aws_ecr_auth \
    --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock \
    --constraint 'node.role == manager' \
    --restart-condition 'none' \
    --detach=false \
    mroca/swarm-aws-ecr-auth

Usage as a swarm container

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name aws_ecr_auth mroca/swarm-aws-ecr-auth

Configuration

By default, this image authenticates the swarm manager onto the AWS ECR for the current region. You can configure the ECR region by setting the AWS_REGION env variable : -e AWS_REGION=eu-west-3, for example.

Requirements

  • The swarm stack must have been created with the https://docs.docker.com/docker-for-aws/ CloudFormation template.
  • The swarm managers must have the AmazonEC2ContainerRegistryReadOnly policy.
  • The services must have been created with --with-registry-auth option.

docker-swarm-aws-ecr-auth's People

Contributors

mroca avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.