Docker on AWS EC2 Instance

Christober S
3 min readJan 23, 2024

--

In this blog I’ll show you how to install docker on EC2 instance

Login to your AWS Account

If you don’t have the AWS Account, just create the free tier version. with that you can create instances.

Search for EC2 Service

Choose the service EC2

Now, let’s create the EC2 instance

choose the name for ec2 instance, which image ubuntu, redhad or windows etc..

Then launch the EC2 instance

Connect to the EC2 instance

We can connect to EC2 instance in number of ways, here we are using Cloud shell

Cloud shell in AWS

Now we have connected to the EC2 instance using the Cloud shell

Here, we can download the Docker

Download Docker in EC2 instance

sudo apt install docker.io
sudo usermod -aG docker $USER
sudo service docker start
ls -l /var/run/docker.sock
sudo chmod 666 /var/run/docker.sock

Use the above commands to download the Docker, sometimes the docker demon will not work so far that you can use the last 3 commands

docker

using docker command we can verify whether it’s installed properly

Running our first docker container

Use the below command to run our first docker conatainer

docker run hello-world

Now, we have successfully download docker and run docker container in our AWS EC2 Instance.

--

--

Christober S
Christober S

Written by Christober S

Student | Cloud | DevOps | Tech Blogger | Public Speaker

No responses yet