[How To] Install Docker on EC2 Linux AMI , CentOS, RHEL, Fedora

Amazon Elastic Computing Cloud also known as Amazon EC2 service offered by Amazon Web Services (AWS) is widely used service for provisioning instances on cloud. Recently, one of my colleague spinned up instance using Amazon Linux 2 Amazon Machine Image (AMI) to use Docker.

Since the AMI doesn't contain Docker preinstalled, he has to install and configure Docker on his own. In this post, we will talk about the steps to install Docker on Amazon Linux 2 operating system.

AWS EC2 AMI Details:

AMI Name - Amazon Linux 2 AMI (HVM)
AMI ID -00dc79254d0461090
Bit - 64-bit x86
Free-tier eligible - Yes

[geeks@terminal ~]$ cat /etc/os-release


NAME="Amazon Linux"
ID_LIKE="centos rhel fedora"
PRETTY_NAME="Amazon Linux 2"

Steps to install Docker on Amazon Linux AMI, CentOS, Fedora & RHELĀ  - 64bit:

Step 1: Login into the server via SSH
Step 2: Update the packages using YUM utility with sudo privilegesĀ 

[geeks@terminal ~]$ sudo yum update -y

Step 3: Install Docker using YUM utility

[geeks@terminal ~]$ sudo yum install docker -y

Step 4: Check the Docker engine version

[geeks@terminal ~]$ docker --version

Step 5: Check if Docker service is running or not

[geeks@terminal ~]$ docker info

If Docker service is not running then start the Docker service

[geeks@terminal ~]$ sudo service docker start

Step 5: Add the user to the Docker group in order to execute the commands without using sudo.

[geeks@terminal ~]$ sudo usermod -a -G docker geeks

In this command, the username is geeks and group name is docker. After successful execution of the command, logout and login with the user for changes to take effect..

Step 6: Verify the installation by running some docker commands.

[geeks@terminal ~]$ docker info
[geeks@terminal ~]$ docker ps

Command to enable starting of Docker service on boot:

 [geeks@terminal ~]$ sudo systemctl enable docker

Command to stop Docker service:

[geeks@terminal ~]$ sudo service docker stop

There are multiple ways to install Docker on Linux distributions. I am providing reference links as below:

CentOS -
Fedora -

That's all folks!

Abhijit Sandhan

Loves Open Source, Blogging, Traveling, Hiking and sharing Knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button