DevOpsDocker

[How To] Install Docker on EC2 Linux , 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

Output:

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

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

[geeks@terminal ~]$ docker info

If Docker service is not running then start the Docker service

[geeks@terminal ~]$ sudo service docker start

Step 5: Add user to the Docker group

This is required so that user can execute the commands without using sudo privileges.

[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

https://docs.docker.com/install/linux/docker-ce/centos/

Fedora

https://docs.docker.com/install/linux/docker-ce/fedora/

That's all folks!

Related Articles

One Comment

  1. Excellent instructions. I just started learning Docker and the installation instructions were right on spot. Great Job on maintaining the instructions.

    Thanks,

Leave a Reply

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

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

Back to top button