Run these commands to have it installed,
unzip awscliv2.zip
cd aws
./install
Run aws --version
cmd, it should return 2.x.x version (of aws cli)
Configure your AWS creds with ECR Registry access with "aws configure"
OR put them
directly by editing the ~/.aws/credentials
file with the right region defined.
Note: Ask your manager or admin for the AWS credentials if you don't have.
Authenticate Docker with AWS ECR in order to pull images into the system (wher Docker is running): Run this cmd without sudo first, if didn't work try adding sudo at the start of this command.
$ aws ecr get-login-password --region <ecr_region> | sudo docker login --username AWS --password-stdin <account_id>.dkr.ecr.<ecr_region>.amazonaws.com
You will see the Login Succeed
message in the console if the command ran successfully
Note: awscli version 2 is required to run this cmd sussessfully, else it'd fail. You'll need to do this step every single time when the session get expire, i.e. When Docker is unable to pull the images from ECR (Pull access denied error)
Edit the main docker-compose.yml file with the image URI like.
....
dashboard:
image: "${ECR_DOCKER_REGISTRY_URI}/dashboard"
container_name: dashboard
volumes:
- tmpfs:/usr/share/nginx/html/tmpfs
- ${CERT_DIR}:${CERT_DIR}
....
Note: If you have the compose_generator script then it will autometically add the ECR image path for the services which will be enabled by user in runtime.
Follow these steps to Run docker-compose with latest ECR images
Step into the docker-compose.yml directory and run the following commands,
Stop containers if there are any running already
$ sudo docker-compose stop
Remove containers along with their images in order to avoid any conflict or confusion
$ sudo docker-compose rm -f
Pull the latest ECR images defined in yaml file
$ sudo docker-compose pull
Run the containers in detach mode
$ sudo docker-compose up -d