Docker has been the new buzz word of Development, Infrastructure and DevOps teams around the world for last two years and I take a long time to understand that Amazon AWS and Docker can live together helping each other and make people happy.
Actually Amazon takes this time too and saw lot of subscribers migrating to another PaaS providers just to use Docker containers instead EC2 instances and their counter attack was offer a complete platform to support Docker containers using all features and benefits of AWS cloud: ECS (EC2 Container Service).
It works as a scheduler resource manager for your Docker containers/architecture offering load balancing, automatic scaling (growth and shrinking), billing by containers and other great and funny stuffs.
In this articleI will talk just about ECR (EC2 Container Registry) and it works as a private docker image repository allowing Docker engineers make your images on their local development environments and publish it in a central repository to your team.
It is very useful to not ask you build your images locally every time you need to install/update some container. For instance imagine you have to update 3 web servers with the same application (Spring Boot app) and in old times you have to copy this artifact to each server and update each one manually or using a Chef or Puppet tooling. If you need to upgrade hardware settings (CPU/RAM/Disk) you need an engineer to do this for you.
With Docker you just have to make your infrastructure and deployment steps as source code (Dockerfile), build it and publish to some registry.
Docker has a public registry named DockerHub but you won’t publish your corporate apps there right? Amazon ECR works as a private registry for you and you just have to pull your images and run it inside your Docker Container Host.
To start using it for you, please follow these steps:
1) goto to ECS
2) If your region doesn’t support it yet, I suggest you to use West Virginia because it is more cheap 😉
3) On you main screen, click on create repository
4) Choose a name for your repository and REMEMBER: this is your image name WITHOUT version. Please create one repository to EACH image
5) Next window will show you the steps to login, build, tag and push.
6) After you push your image you will see something like this:
7) To use it on server to run it you just have to
eval $(aws ecr get-login --region us-east-1)
docker pull 630093251828.dkr.ecr.us-east-1.amazonaws.com/base-ubuntu:16.10-20161010
docker run --name ubuntu -it 630093251828.dkr.ecr.us-east-1.amazonaws.com/base-ubuntu:16.10-20161010 /bin/bash
In this case I built a base image for Ubuntu 16.10 containing some default settings and locale set to en_US.UTF-8 (I will talk about it in other post).
I expect you enjoy this little HOWTO.