Install Docker CE on Amazon Linux 2
Here is how to install docker and docker-compose on the (AWS) Amazon Linux 2 OS running on either an EC2 or Lightsail instance.
Let’s begin by opening a console or SSH session to your EC2 or Lightsail instance. You can do this from within your AWS portal or an SSH tool like Putty. The actual “how to connect” to your server is outside the scope of this article.
Once you are connected, let us start by installing any pending updates on your host.
sudo yum update
Next, we will install Docker.
sudo yum install docker
Create a new membership group for docker and add the ec2-user to it so you can run all of the docker commands without needing to use the sudo command.
sudo usermod -a -G docker ec2-user id ec2-user newgrp docker
Now it’s time to add docker-compose.
wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose sudo chmod -v +x /usr/local/bin/docker-compose
Enable the docker service.
sudo systemctl enable docker.service
Start the docker service.
sudo systemctl start docker.service
Verify that the service is running.
sudo systemctl status docker.service
You can check the docker version with this command.
And lastly you can check the docker-compose version with this command..
You have now installed docker and docker-compose on Amazon Linux 2.
I am going to leave off with some helpful controls manage docker on your machine.
sudo systemctl start docker.service #start docker sudo systemctl stop docker.service #stop docker sudo systemctl restart docker.service #restart docker sudo systemctl status docker.service #get the status of docker