Default Linux on AWS EC2 doesn’t provide Docker and Docker Compose. We have to install them manually.
Version
Docker 20.10.7
Update Package List
$ sudo yum update -y
Update package list to latest version.
Add Docker
$ sudo amazon-linux-extras install docker
Add docker to system.
Start Docker
$ sudo service docker start
Start Docker as service.
Docker Group
$ sudo usermod -a -G docker ec2-user
Add ec2-user
to docker
group.
Docker Info
$ docker info
Re-login SSH, we can run Docker command without sudu
becuase we’ve added ec2-user
to docker
group.
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
Add Docker Compose to system.
$ docker-compose version
Docker compose installed successfully.
Conclusion
- After installing Docker and Docker Compose on AWS EC2, we can use Docker just like using it on local machine
Reference
AWS, Docker basics for Amazon ECS
AWS, Launch an instance using the Launch Insance Wizard