install docker on ec2 code example
Example 1: Amazon Linux 2 AMI install docker
sudo yum update -y
sudo amazon-linux-extras install docker
sudo service docker start
Example 2: how to install and enable docker on command line with EC2 instance
sudo yum update -y
sudo amazon-linux-extras install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -a -G docker ec2-user (to avoid sudo command usage)
newgrp docker (to avoid sudo command usage)
Example 3: how to setup dockers on aws
sudo yum update -y
sudo amazon-linux-extras install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo chkconfig docker on
sudo yum install -y git
sudo curl -L https://github.com/docker/compose/releases/
latest/download/docker-compose-$(uname -s)-$(uname -m)
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Example 4: install docker ec2
sudo service docker start