Table of Content
-
Login to docker
docker login
-
Login to AWS ECR (try skip this step)
AWS_PROFILE=terraform $(aws ecr get-login --no-include-email --region eu-central-1)
NOTE. Command above should automatically login to AWS ECR, if it isn’t true, you should try to run command without
$(...)
, justAWS_PROFILE=terraform aws ecr get-login --no-include-email --region eu-central-1
Then copy and past output to CLI
-
Run docker build
docker build --no-cache -t tb/web -f .docker/php/Dockerfile .
--no-cache
option can be omitted.
-f
option point the path to Dockerfile
.
dot at the end is required -
Create repository (Optional)
aws ecr create-repository --repository-name tb/web
The response back from the CLI should look something like this:
{
"repository": {
"registryId": "<aws-account-id>",
"repositoryName": "tb/web",
"repositoryArn": "arn:aws:ecr:eu-central-1:<aws-account-id>:repository/tb/web",
"createdAt": 1514064542.0,
"repositoryUri": "<aws-account-id>.dkr.ecr.eu-central-1.amazonaws.com/tb/web"
}
}
-
Create tag (Optional)
docker tag tb/web <aws-account-id>.dkr.ecr.eu-central-1.amazonaws.com/tb/web
-
Authenticate Docker to an Amazon ECR registry
$(aws ecr get-login --no-include-email --region eu-central-1)
-
Push docker image to AWS
docker push <aws-account-id>.dkr.ecr.eu-central-1.amazonaws.com/tb/web