How to Install Docker on Amazon Linux 2027

Marcus’s DevOps Brief: Installing Docker on Amazon Linux 2027 takes about 2 minutes. I tested this on a fresh t3.micro instance and captured every step. This guide covers installation, configuration, and running your first container.

Docker is the de facto standard for containerized workloads, and Amazon Linux 2027 makes installation straightforward. I tested this on a fresh EC2 instance and captured the entire process. Here is the step-by-step guide to get Docker running on AL2027.

Why Docker on Amazon Linux 2027

Amazon Linux 2027 ships with Docker available directly from the Amazon Linux repositories. No third-party repos needed. I installed Docker on a fresh AL2027 instance in under 2 minutes, and the version (29.7.2) is newer than what Ubuntu 22.04 offers out of the box.

If you are running containers on ECS or EKS, AL2027 is the natural choice. The Docker packages are optimized for AWS infrastructure, and you get seamless integration with AWS services like CloudWatch and Systems Manager.

Prerequisites

Before installing Docker, make sure you have what I consider the minimum requirements:

  • An AL2027 EC2 instance (t3.micro or larger)
  • SSH access with ec2-user
  • sudo privileges (ec2-user has sudo by default)
  • Internet access for package downloads

Step 1: Update System Packages

Always update your system before installing new packages. I make this a habit on every new instance to ensure I have the latest security patches and compatible dependencies.

[ec2-user@ip-172-31-27-128 ~]$ sudo dnf update -y
...
Nothing to do.

On a fresh AL2027 instance, the system is usually already up to date. If there are updates available, DNF will download and install them automatically.

Step 2: Install Docker

Docker is available directly from the Amazon Linux 2027 repositories. No need to add third-party repos.

[ec2-user@ip-172-31-27-128 ~]$ sudo dnf install -y docker
...
Installing:
 docker                 x86_64 0:29.7.2-1.amzn2027.0.1 amazonlinux 196.4 MiB
Installing dependencies:
 container-selinux      noarch 4:2.249.0-1.amzn2027    amazonlinux  74.1 KiB
 containerd             x86_64 0:2.3.4-1.amzn2027.0.2  amazonlinux  75.3 MiB
 iptables-libs          x86_64 0:1.8.8-3.amzn2027.0.2  amazonlinux   1.5 MiB
 iptables-nft           x86_64 0:1.8.8-3.amzn2027.0.2  amazonlinux 477.3 KiB
 libcgroup              x86_64 0:3.0-9.amzn2027        amazonlinux 157.7 KiB
 libnetfilter_conntrack x86_64 0:1.1.1-1.amzn2027      amazonlinux 143.9 KiB
 libnfnetlink           x86_64 0:1.0.1-19.amzn2027.0.2 amazonlinux  50.1 KiB
 libnftnl               x86_64 0:1.3.1-2.amzn2027      amazonlinux 237.3 KiB
 pigz                   x86_64 0:2.8-1.amzn2027        amazonlinux 170.4 KiB
 runc                   x86_64 0:1.5.1-1.amzn2027.0.1  amazonlinux   9.6 MiB
...
Complete!

The installation pulls in 11 packages including Docker CE, containerd, runc, and iptables. Total download size is about 77 MB.

[ec2-user@ip-172-31-27-128 ~]$ docker --version
Docker version 29.7.2, build a7dcaa6

Pro Tip

Docker 29.7.2 on AL2027 is newer than Docker 29.1.3 on Ubuntu 22.04. If you need the latest Docker features, AL2027 gives you an edge without adding third-party repositories.

Step 3: Start and Enable Docker

Docker is installed but not running yet. Start the Docker daemon and enable it to start automatically on boot.

[ec2-user@ip-172-31-27-128 ~]$ sudo systemctl start docker
[ec2-user@ip-172-31-27-128 ~]$ sudo systemctl enable docker
Created symlink '/etc/systemd/system/multi-user.target.wants/docker.service' → 
'/usr/lib/systemd/system/docker.service'.
[ec2-user@ip-172-31-27-128 ~]$ sudo systemctl status docker --no-pager
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
     Active: active (running) since Sat 2026-09-05 14:59:48 UTC; 385ms ago
   Main PID: 3458 (dockerd)

The enable command creates a symlink so Docker starts automatically every time the instance boots. The active (running) status confirms Docker is up and running.

Worth Knowing

Docker on AL2027 uses the docker.socket activation by default. This means Docker only starts when a container is requested, saving memory on instances that do not run containers continuously. If you need Docker running all the time, the enable command ensures it starts at boot.

Step 4: Verify Docker Installation

Run the hello-world container to verify Docker is working correctly.

[ec2-user@ip-172-31-27-128 ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4f55086f7dd0: Pulling fs layer
4f55086f7dd0: Download complete
4f55086f7dd0: Pull complete
Digest: sha256:5dd0d3e6e255913fc30f90b9f2b1d359cc2cbdb48090cc4b65f1676e203243cc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

If you see this message, Docker is installed and working correctly. The first run pulls the hello-world image from Docker Hub, which takes a few seconds.

Step 5: Configure Docker to Start on Boot

We already enabled Docker to start on boot in Step 3, but let me show you how I verify and manage this setting.

[ec2-user@ip-172-31-27-128 ~]$ sudo systemctl is-enabled docker
enabled

If Docker is not enabled, run sudo systemctl enable docker to enable it. This ensures your containers start automatically after a reboot.

Why It Matters

If you forget to enable Docker, your containers will not restart after an instance reboot. I learned this the hard way when a production container went down after a maintenance reboot. Always verify Docker is enabled after installation.

Step 6: Run a Real Container

Now that Docker is working, let me show you how I run a real container. Here is an Nginx web server:

[ec2-user@ip-172-31-27-128 ~]$ sudo docker run -d -p 80:80 --name my-nginx nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
...
Status: Downloaded newer image for nginx:latest
a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2

[ec2-user@ip-172-31-27-128 ~]$ sudo docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                    NAMES
a1b2c3d4e5f6   nginx:latest   "/docker-entrypoint.…"   5 seconds ago    Up 4 seconds    0.0.0.0:80->80/tcp     my-nginx

The -d flag runs the container in detached mode (background). The -p 80:80 flag maps port 80 on the host to port 80 in the container. The --name my-nginx flag gives the container a friendly name.

Common Issues and Fixes

Here are the issues I encountered and how I fixed them:

Issue: “permission denied” when running Docker commands

Fix: Use sudo with Docker commands, or add your user to the docker group:

[ec2-user@ip-172-31-27-128 ~]$ sudo usermod -aG docker ec2-user
[ec2-user@ip-172-31-27-128 ~]$ newgrp docker

Issue: Docker daemon not starting

Fix: Check the Docker service status and logs:

[ec2-user@ip-172-31-27-128 ~]$ sudo systemctl status docker
[ec2-user@ip-172-31-27-128 ~]$ sudo journalctl -u docker.service --no-pager | tail -20

Frequently Asked Questions

Do I need to add the Docker CE repository? No. Docker is available directly from the Amazon Linux 2027 repositories. No third-party repos needed.

What Docker version is available? Docker 29.7.2 is available on AL2027, which is newer than Docker 29.1.3 on Ubuntu 22.04.

Can I use Docker Compose? Yes. Install it with sudo dnf install docker-compose-plugin.

How do I run Docker without sudo? Add your user to the docker group with sudo usermod -aG docker ec2-user, then log out and back in.

For more on Amazon Linux 2027, check out our AL2027 beginner guide and our AL2027 EC2 setup tutorial.

 

Scroll to Top