To install Docker on an Amazon EC2 instance
Launch an instance with the Amazon Linux 2 or Amazon Linux AMI (ignore this step if you already have set up EC2 instance
- Connect to your instance -- using ssh
- Update the installed packages and package cache on your instance - using the following command
sudo yum update -y - Install the most recent Docker Engine package - using the following command
sudo yum install docker - Start the Docker service - using the following command
sudo service docker start - Add the ec2-user to the docker group so you can execute Docker commands without using sudo. - using the following command
sudo usermod -a -G docker ec2-user - Log out and log back in again to pick up the new docker group permissions. You can accomplish this by closing your current SSH terminal window and reconnecting to your instance in a new one. Your new SSH session will have the appropriate docker group permissions.
- Verify that the ec2-user can run Docker commands without sudo. - using the following command
docker info - Verify that Docker Engine is installed correctly by running the hello-world image -- - using the following command
docker run hello-world
Reference : Docker basics for Amazon ECS