How to install Docker on Amazon Linux 2

Login to your amazon linux 2 machine using putty.

If you have not created the amazon linux 2 instance then create it first before proceeding with the next step. Copy the public ip of your ec2 instance and paste in the address bar or host address of putty.

docker on amazon linux

Now click on SSH on the left hand side of the putty configuration and attach the public key of your ec2 instance.

amazon linux

Once you have browse and attached your public key, click open and enter ec2-user when prompted for username

Once logged in, first switch to root user and run yum update -y to update the package on amazon linux machine

$sudo su
# yum update -y
yum update

By Default, Amazon linux 2 doesnt have docker repository available. We need to attach the docker repository first and then install docker

Run below command to enable the docker resository for amazon linux and install docker

Install Docker on Amazon linux

$sudo amazon-linux-extras install docker
amazon linux

Now the docker is installed successfully on amazon linux 2

Now lets check the docker version which is installed on the linux machine

#docker --version

Now lets start the docker daemon service and enable the docker service so that it can auto start across reboots.

#systemctl enable docker
#systemctl start docker

Finally, we will check the status of the docker service

#systemctl status docker

Conclusion:

We have successfully installed docker on amazon linux 2 and have verified the installed docker version. Also we have started docker service and verified its running status. Refer Articles related to docker.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments