- Log into AWS Console
- Search AWS Service
ECS
- Select
Repositories
from the left menu under "Amazon ECR"
- Select
Create repository
- Retrieve the docker login command that you can use to authenticate your Docker client to your registry
aws ecr get-login --no-include-email --region us-west-2
- Run the docker login command that was returned in the previous step.
Invoke-Expression -Command (aws ecr get-login --no-include-email --region us-west-2)
- Build your Docker image using the following command. You can skip this step if your image is already built:
docker build -t YOUR-IMAGE-NAME .
- After the build completes, tag your image so you can push the image to this repository.
docker tag YOUR-IMAGE-NAME:TAG-VERSION YOUR-AWS-REPO-URI/YOUR-IMAGE-NAME:TAG-VERSION
- Run the following command to push this image to your newly created AWS repository:
docker push YOUR-AWS-REPO-URI/YOUR-IMAGE-NAME:TAG-VERSION
- SSH into your EC2
- (Optional) Search for ECR Repositories
aws ecr describe-repositories --region us-west-2
- (Optional) Describe image within a ECR Repository
aws ecr describe-images --repository-name amazonlinux
- Docker pull ECR image to your EC2
docker pull AWS-ACCOUNT-ID.dkr.ecr.us-west-2.amazonaws.com/YOUR-IMAGE-NAME:TAG-VERSION
- Run pulled docker image
docker run -d --env-file .env --name NEW-IMAGE-NAME -p "80:80" NAME-OF-DOCKER-IMAGE