How to install Docker on an Amazon EC2 instance Linux 2

To install Docker on an Amazon EC2 instance running Linux 2, you must first log in to your instance using SSH. Once you are logged in, you can use the following steps to install Docker:

  • Update the package manager index by running the following command:
$sudo yum update
  • Install the docker package by running the following command:
$sudo yum install docker
  • Start the Docker service by running the following command:

    $ sudo service docker start
    
  • Verify that Docker is running by running the following command:

    $ sudo service docker status
    

You should see an output

After following these steps, Docker should be installed and running on your Amazon EC2 instance. You can now use Docker to run and manage containers on your instance.