Satvir Matharu Blog

We provide latest Technology Tips, tricks and solutions regarding Android and Windows OS with Technical Videos.

What Is AWS Docker Containers On AWS & Deploy on EC2

What Is AWS Docker Containers On AWS & Deploy on EC2

Hi there to the beautiful people reading this blog of mine, setting up docker for aws in an ec2 instance sounds tough, but is not. I will figure this out with these nice and easy steps. I will walkthrough you people to the installation of both docker and docker compose. We will be showing you what is aws docker and docker containers on aws.

Is EC2 and Docker are same ?

Some of you might have the question or confusion regarding is AWS EC2 and AWS Docker are same ! So answer is simple No. EC2 is a virtual machine whereas, Docker is all different technology.

What is an EC2 instance

An Amazon EC2 instance is a virtual server in Amazon’s Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure. AWS is a comprehensive, evolving cloud computing platform; EC2 is a service that enables business subscribers to run application programs in the computing environment. It can serve as a practically unlimited set of virtual machines (VMs).

What is AWS Docker

Docker with aws is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc.

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

Also Read: Deploy AWS ALB- Application Load Balancer


  1. AWS account

2. Very basic knowledge of Docker and AWS

Steps to create AWS EC2 Instance and docker

Try this : Create Own Media Server Like Netflix

First let’s create an ec2 instance

Sign in to your AWS account, hop into the ec2 dashboard and launch an ec2 instance. you can search EC2 in search bar on AWS portal to easily get into to EC2 dashboard.

AWS Docker
AWS EC2 Dashboard

Click on instances, this will show you the list of instance if you have any

You might like: How to Secure A PDF File

Click on launch instances to create a aws ec2 instance for aws docker.

AWS Docker
Launch Instance

I named my ec2-instance as docker-ec2, you can name it any you want

AWS Docker
Name your ec2 instance

t2-micro and proceed without keypair

I am assuming you know how to SSH into an EC2 instance with a keypair, in case if you don’t know just let me know in the comment section ,there will be a blog soon on it.

Read Also: Best Way Send Confidential Emails In 2022

AWS Docker
Proceed without keypair if you are the admin

or you can login with the key pair

AWS Docker

Let’s chop in some commands for setting up docker in this ec2-instance

AWS Docker

Try this: How Easy Is Register Your Business On Google in 2022

Commands for installation of docker

sudo yum update
sudo yum search docker
sudo yum info docker 
sudo yum install docker 

Above commands search for aws docker package and then install it on your aws instance .

Now, docker is installed successfully, now we just need to enable this docker service in order to make our docker commands to work

sudo systemctl enable docker.service 
sudo systemctl start docker.service

In order to give sudo/ admin rights to the docker or in order to make docker commands to work without writing sudo ahead of them we need to add docker service to the admin group we can do this by using these commands. These commands will start the aws docker services on your EC2 instance

sudo groupadd docker 
sudo usermod -aG docker $USER

You can make sure that your docker installation is successful by using command. Run the above commands to add your user to aws docker group so that user can use dockers.

docker --version

This will give you the version of the docker installed in the console. Here’s the end if you just want to work with AWS docker in AWS EC2, instance or you can follow along if you want to know about how docker-compose installation will be done in AWS EC2 instance.

Just in case command if you get permission denied error while running docker commands

sudo chmod 666 /var/run/docker.sock  

Commands for installation of docker compose in case you want your yaml files/ docker-compose.yaml files to work in ec2 or commands like docker-compose up to work.

wget$(uname -s)-$(uname -m)

sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose

sudo chmod -v +x /usr/local/bin/docker-compose

Just in case command if you get permission denied error while doing docker-compose up

sudo chmod 666 /var/run/docker.sock  

Now, you can check if docker-compose is successfully installed by using the command

docker-compose --version

This will give you the version of docker-compose installed in the console as an output.

That’s it.


This is how we can install AWS docker on our AWS EC2 instance and now you can easily run your docker image and “docker-compose.yml” files in the instance. In case you want to know more about docker and aws or how to SSH into your EC2 instance with a keypair just let me know in the comment section and there will a blog on it soon 😉.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
%d bloggers like this: