Adaptive Logo
Product
View Product
Use Cases
View Product
Resources
View Product
Pricing
Partners
Careers
Cheatsheet 2 min read

How to setup Docker on AWS Linux in under 5 minutes

Debarshi BasakJul 20, 2023

Docker is the fastest way to package and run applications on an EC2 instance. If you are on an Amazon Linux box, you can have the Docker engine up and running in a couple of minutes. This cheatsheet walks through the install for both Amazon Linux 2 and Amazon Linux 2023.

Prerequisites

  • An EC2 instance running Amazon Linux 2 or Amazon Linux 2023.
  • SSH access to the instance (the default user is ec2-user).
  • sudo privileges.

If you need help connecting to your instance, see our guide on how to set up an AWS bastion host or a jump server.

Step 1 — Update the package index

SSH into your instance and make sure existing packages are up to date.

sudo yum update -y

On Amazon Linux 2023, yum is symlinked to dnf, so the same command works.

Step 2 — Install Docker

Amazon Linux 2

Amazon Linux 2 ships Docker in the Amazon Linux Extras repository:

sudo amazon-linux-extras install docker -y

Amazon Linux 2023

On Amazon Linux 2023, Docker is available directly from the default repositories:

sudo dnf install docker -y

Step 3 — Start the Docker service

Start the Docker daemon and enable it so it survives reboots.

sudo systemctl start docker
sudo systemctl enable docker

Verify the service is running:

sudo systemctl status docker

Step 4 — Run Docker without sudo

By default you need sudo for every Docker command. Add your user to the docker group so you can run Docker directly.

sudo usermod -aG docker ec2-user

Log out and back in (or run newgrp docker) for the group change to take effect.

Step 5 — Verify the installation

Check the version and run a test container:

docker --version
docker run hello-world

If you see the "Hello from Docker!" message, your engine is working.

Optional — Install Docker Compose

To orchestrate multi-container apps, install the Compose plugin. For a full walkthrough, see installing Docker Compose in Linux.

docker compose version

A note on access and auditing

Giving developers SSH keys to EC2 hosts running Docker means standing credentials and limited visibility into who ran what. With Adaptive, teams get Just-in-Time, credential-less access to their infrastructure — including SSH and AWS — with every session logged and auditable.

That's it — Docker on Amazon Linux in well under five minutes.

Agents are the new perimeter. Contain the chaos.
No Network Changes Required
Cloud or On-Premises Deployment
Enterprise-Grade Security