Skip to content
GitHub Twitter

Install Docker on Amazon Linux 2

Install Docker on Amazon Linux 2

Docker, a popular platform for containerization, enables developers to create, deploy, and run applications in isolated environments called containers. If you are using Amazon Linux 2 as your operating system on AWS, this tutorial will guide you through the process of installing Docker. By following these steps, you will be able to utilize Docker's powerful capabilities to streamline your application deployment workflow.

Step 1: Connect to Your Amazon Linux 2 Instance

To begin, ensure that you have successfully logged into your Amazon Linux 2 instance. You can use SSH or connect to your instance using AWS Management Console.

Step 2: Update System

Before proceeding with the installation, it is essential to update your system packages. Open the Terminal or SSH into your instance and run the following command:

sudo yum update -y

This command will update your system packages to the latest versions.

Step 3: Install Docker

Amazon Linux 2 comes with amazon-linux-extras installed. To Make sure you have amazon-linux-extras installed, run the following:

which amazon-linux-extras

It should output the location of amazon-linux-extras such as /usr/bin/amazon-linux-extras, If not install amazon-linux-extras using yum

yum install -y amazon-linux-extras

then enable docker by running the following command:

amazon-linux-extras enable docker

then install docker by running the following command:

yum install -y docker

Step 4: Start Docker

sudo service docker start

Step 5: Add ec2-user Permissions

sudo usermod -a -G docker ec2-user
sudo chmod 666 /var/run/docker.sock
docker version