Troubleshooting: AWS ECS Deploy Containerized Flask Application
Overview
- Create an AWS Account
- Install and Configure AWS CLI
- Install Docker
- Create a or clone flask application with a docker file
- Create Docker Image from
Dockerfile
- Run and View Docker Image Locally
- Create Repository in ECS Registry
Create Docker Image from Dockerfile
- Execute the command below from the root directory of the newly created project
Dockerfile
docker build -t my-flask-app .
Troubleshooting
Command Fails Without Docker Daemon Running
Command Fails With Docker Daemon Running
Ensure Docker Credential Desktop Executable is on Path
- Execute the command below to ensure
docker-credential-desktop.exe
is on Pathdocker-credential-desktop.exe version
Rename credsStore to credStore
- In
~/.docker/config.json
changecredsStore
tocredStore
Re-attempt to build the image
Run Docker Image
- Execute the command below from the root directory of the project
docker run -p 80:80 my-flask-app
- View the application by navigating the to the link below
Create Repository in Elastic Container Registry
Execute the command below to create a repository in the elastic container registry
aws ecr create-repository --repository-name my-flask-application-01.06.2021
Authenticate with newly created ECR repo
- Execute the command below to print a command used to log into the newly created ECR repository.
aws ecr get-login --region us-east-1 --no-include-email
- Copy the output of that command.
- Paste and run the output in the terminal.
- This will actually authenticate you with the ECR so you can push your Docker image into it.
Push to newly authenticated repo
- Execute the commands below to
tag
andpush
the image to the AWS ECR (whereACCT_ID
is your own AWS account ID)- Execute command below to tag image
docker tag my-flask-app:latest ACCT_ID.dkr.ecr.us-east-1.amazonaws.com/
- Execute command below to push image up to AWS ECR
docker push ACCT_ID.dkr.ecr.us-east-1.amazonaws.com/hello-world
- Execute command below to tag image