In this step by step tutorial, I show you how to deploy a Flask based Docker app to AWS. We start by building a local docker image and uploading it to Elastic Container Registry. We create an ECS Cluster, and configure a task to run our docker image. Finally, we launch a Task into the cluster and expose the app to the internet via VPC.
00:10 Example Overview
02:15 Application Walkthrough
04:34 Creating a ECR Repository
05:16 Uploading your Image to ECR
06:28 Creating an ECS Cluster
09:10 Creating a ECS Task Definition
11:35 Running a Task on your Cluster
13:03 Testing our app
Want the docker file used in this video? Check out https://docker-curriculum.com/ Tutorial (about a third down the page). https://docker-curriculum.com/
How to install the AWS CLI – https://youtu.be/jCHOsMPbcV0
Source Code + Policy Template – https://gist.github.com/awssimplified/da49577fa48128e1da992dd6ec21085c
šSUPPORT BE A BETTER DEVš
Become a Patron: https://www.patreon.com/beabetterdev
š MY RECOMMENDED READING LIST FOR SOFTWARE DEVELOPERSš
Clean Code – https://amzn.to/37T7xdP
Clean Architecture – https://amzn.to/3sCEGCe
Head First Design Patterns – https://amzn.to/37WXAMy
Domain Driver Design – https://amzn.to/3aWSW2W
Code Complete – https://amzn.to/3ksQDrB
The Pragmatic Programmer – https://amzn.to/3uH4kaQ
Algorithms – https://amzn.to/3syvyP5
Working Effectively with Legacy Code – https://amzn.to/3kvMza7
Refactoring – https://amzn.to/3r6FQ8U
š MY RECORDING EQUIPMENT š
Shure SM58 Microphone – https://amzn.to/3r5Hrf9
Behringer UM2 Audio Interface – https://amzn.to/2MuEllM
XLR Cable – https://amzn.to/3uGyZFx
Acoustic Sound Absorbing Foam Panels – https://amzn.to/3ktIrY6
Desk Microphone Mount – https://amzn.to/3qXMVIO
Logitech C920s Webcam – https://amzn.to/303zGu9
Fujilm XS10 Camera – https://amzn.to/3uGa30E
Fujifilm XF 35mm F2 Lens – https://amzn.to/3rentPe
Neewer 2 Piece Studio Lights – https://amzn.to/3uyoa8p
š» MY DESKTOP EQUIPMENT š»
Dell 34 inch Ultrawide Monitor – https://amzn.to/2NJwph6
Autonomous ErgoChair 2 – https://bit.ly/2YzomEm
Autonomous SmartDesk 2 Standing Desk – https://bit.ly/2YzomEm
MX Master 3 Productivity Mouse – https://amzn.to/3aYwKVZ
Das Keyboard Prime 13 MX Brown Mechanical- https://amzn.to/3uH6VBF
Veikk A15 Drawing Tablet – https://amzn.to/3uBRWsN
š References:
Getting started with AWS: https://youtu.be/lTyqzyk86f8
āTopics covered include:
Docker
Flask App
Elastic Container Registry
Elastic Container Service
š Find me here:
Twitter – https://twitter.com/BeABetterDevv
Instagram – https://www.instagram.com/beabetterdevv/
Patreon – Donations help fund additional content – https://www.patreon.com/beabetterdev
#SoftwareEngineer
#SoftwareDeveloper
#ElasticContainerService
#AWS
source
For anyone getting this error: CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:338: getting the final child's pid from pipe caused: read init-p: connection reset by peer: unkno
The cause is there's not enough memory assigned for your Task. If you followed along to the video, in task definition, change memory from 1 to 512 and CPU to 512 as well. Hope it helps
You sir are a lifesaver! I've been trying to figure this out for a week.
I do have a question. I created the ECS cluster but i don't see any ECS instances, even though i have an image pushed to ECR. Any idea what i'm missing?
Thank you for this !
@ 2.50 the command typed is docker built
Man! I wanna hug you! I suffered for about a month through bullshitery guides from amazon on how to do it! But you explained it so simply! Now I will need to make a pipeline with autodeploy. I hope you'll have videos on that topic. THANK YOU once again for such clear explanation.
I dont see an EC2 instance with my ECS Instance.
As you see an instance being created at 8:26 and then at 9:07, my window shows no results.
Also when I run the task as you have done it at 12:12, it throws an error:
Unable to run task
No Container Instances were found in your cluster.
I would really appreciate your help, thanks.
Thanks mate!!!
Does this tutorial works if I try to deploy a SB application with MySQL using docker compose?
Where can I get the flask app code
Tasks are similar to deployment in k8s
Load balancer target group?
Thank you!
Hi, i have the same error on the running task.
Subscribed
The Flask application works without any problem . Thanks a lot for this important example.then I have tried to deploy a django application on a ecs container following your instructions.
I am afraid that the T2micro is too small to load a imagine of 1.24 Gb .
Hello, it's very strange I have done exactly the same and i have this error:
CannotStartContainerError: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: container init was OOM-killed (memory limit too low?): unknown
Great video Thanks a lot. I tryed many times to do this but only with your video I solved the problem very very great thanks
4:50 why you skip part of aws for creating role and enable ecr:GetAuthorizationToken ?!!
Great tutorial, I have a question. I have a similar set-up and wonder if there is any way to handle clients loosing connection each time you make a deployement? E.g every time I deploy the users that were authenticated and signed in to the site gets kicked out since the container with redis gets cleared
nice, thanks!
Hi great video. I followed this along but got stuck where the task was pending status. Can you show me how you fixed it exactly? I was following exactly what you were doing.. I donāt know what typo you made.. is that container name ?