Guide for AWS commands
Here you will only find the useful commands, for more info check out the docs.
Requirements
- Access key
- Secret key
- AWS ECR CLI (see docs how to install)
Setup AWS CLI
Run:
$ aws configure
Or add config file and credentials file to ~/.aws/ directory.
~/.aws$ cat credentials
[default]
aws_access_key_id = your-key
aws_secret_access_key = you-secret-key
Login
If you got credentials in place go ahead and login. The login command will store password locally with some encode method for one day (check the feedback after login for where the file is stored). Every day new login is needed.
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin <your-subdomain>.dkr.ecr.eu-west-1.amazonaws.com
Create repos
aws ecr create-repository --repository-name your/repo --image-scanning-configuration scanOnPush=true --region eu-west-1
List repos
aws ecr describe-repositories
Describe one repo
aws ecr describe-repositories --repository-name olpr/olpr-cli
List images in repo
aws ecr list-images --repository-name your-repo
Build an image ready for push
$ docker build -t <your-subdomain>.dkr.ecr.eu-west-1.amazonaws.com/your/repo:your_tag .
Note: You need a ./Dockerfile to be able to run this command.
Tag existing image for AWS ECR registry
$ docker tag your/repo:your_tag <your-subdomain>.dkr.ecr.eu-west-1.amazonaws.com/your/repo:your_tag
Note: You need the your/repo:your_tag image in your local images list. Check with docker image ls -a.
Push image to AWS ECR
$ docker push <your-subdomain>.dkr.ecr.eu-west-1.amazonaws.com/your/repo:your_tag
Delete images (permission)
$ aws ecr batch-delete-image --repository-name your/repo --image-ids imageTag=your_tag