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
Login to AWS ECR (Tokens are valid for 12 hours only)
eval $(aws ecr get-login --no-include-email --region region-name)
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.
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.