简体   繁体   中英

Make docker-swarm update from ECR

How can I make docker-swarm connect to ECR and update the current container with the latest image. If yes, please share with an article where can I start my investigation.

On whichever node you're using to control your docker swarm, log into ECR and pull the latest image, with this command: eval $(aws ecr get-login --no-include-email --region <whatever-your-region-is>)

This will log in to your ECR registry. Note that you'll need to add your AWS access key and secret key to this node for this to work; if you haven't done this already, do so with the aws configure command.

Now, when you run docker stack deploy to start your container(s), add the --with-registry-auth flag to the command: this "spreads" the login to all the nodes in your swarm so they can all download the image.

Basically you need two things

  1. Login to AWS ECR (Tokens are valid for 12 hours only)

    eval $(aws ecr get-login --no-include-email --region region-name)

  2. Update your docker services

    docker service update -d -q --with-registry-auth service-name

Note: Make sure in your service definition the docker image has the suffix latest. eg docker_image_name:latest

This article describes exactly how to automatically login to AWS ECR and update docker services.

http://issamben.com/docker-swarm-ecr-auto-login/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM