Docker – How to Install Docker on AWS EC2 Instance with AMI

amazon ec2amazon-amiamazon-web-servicesdockerinstallation

What is the current way of installing Docker on an AWS EC2 instance running the AMI?
There has been an announcement of Docker Enterprise Edition and now I want to know if anything has changed.
Until now, I have been using yum install docker and do get a Docker versioned at 1.12.6, build 7392c3b/1.12.6 right now (3/3/2017). However, the Docker repository on GitHub tells me that there are already newer releases.

I remember the official Docker (package) repository having a package named docker-engine replacing docker some time ago and now they seem to split the package up into docker-ce and docker-ee, where e.g. "Docker Community Edition (Docker CE) is not supported on Red Hat Enterprise Linux." [Source]

So is or will it still be correct to use the above to get the latest stable Docker version on EC2 instances running the AMI or do I need to pull the package from somewhere else (and if so which one, CE or EE)?

Best Answer

To get Docker running on the AWS AMI you should follow the steps below (these are all assuming you have ssh'd on to the EC2 instance).

  1. Update the packages on your instance

    [ec2-user ~]$ sudo yum update -y

  2. Install Docker

    [ec2-user ~]$ sudo yum install docker -y

  3. Start the Docker Service

    [ec2-user ~]$ sudo service docker start

  4. Add the ec2-user to the docker group so you can execute Docker commands without using sudo.

    [ec2-user ~]$ sudo usermod -a -G docker ec2-user

You should then be able to run all of the docker commands without requiring sudo. After running the 4th command I did need to logout and log back in for the change to take effect.

Related Topic