Over the past weekend, I was playing around with deploying .NET Core Docker images to Amazon AWS. I wanted to utilize their EC2 Container Repository (ECR) to keep everything self-contained. My initial tinkering turned out pretty well. I’ll have a better walk-through once I have everything working as I want.
At any rate, here are a few notes I made to myself for the steps I went through, which I thought I’d share. These steps detail building/deploying Docker containers to AWS using EC2 with the EC2 Container Repository (ECR). Docker images were made directly from VS2017 using Docker CE (Docker Compose).
I ran all of this in a Win10 VM (VMWare) set to machine type of Hyper-V which allows Hyper-V to be enabled in the VM, which is required by Docker CE.
I basically had everything working up to the point of defining the Task / Cluster to run the image (and allow scaling).
I followed instructions here for creating an Instance (up to and including step 5). It was good enough to explain the IAM roles / users / etc.
Created a private ECR Repository.
Set up Putty for SSH access:
After the instance/user/security roles were created, I set up AWS CLI:
The keys needed for the AWS CLI are available under the IAM console:
Installed Docker on the Instance:
Account ID is found here:
I added Docker support to the CSOKI aspnet-core-template project w/ Docker CE set to build Linux images and ran ‘Build’ from VS2017. Afterward, I followed this guide for pushin the image:
Retrieve the docker login and everything needed for docker from here (command run from local command prompt):
The repository URI is also available here (region specific):
RepoUrl is in the format [accountid].dkr.ecr.[region].amazonaws.com/[ecr-repo-name]
… get ecs login -> aws ecr get-login –no-include-email –region us-west-2
… docker login from prev command….
docker tag [imageid] [repoUrl]
docker push [repourl]
In Putty over SSH to the EC2 instance – to test image:
logged-in via the docker login command (same as above from AWS CLI setup)
docker pull [repoUrl]
docker run -p 80:80 [repoUrl]