How To Install Docker CE on Amazon Linux 2023

Docker is a software tool created to enable users create, deploy and manage applications using containers. The concept of containers has witnessed tremendous adoption in the past couple of years. As a developer, containers allows you to package up applications with all of its dependencies which include libraries and deploy it as one package. This guide will show you how to install and use Docker CE on Amazon Linux 2023.

Applications packaged as containers can run on any other Linux machine regardless of the environment, distribution type or customizations which distinguish source machine and the destination server where containers are run. We will update the OS, install some few dependencies then install Docker CE on Amazon Linux 2023 server.

Install Docker CE on Amazon Linux 2023

Before we start the update, let’s ensure our system is updated.

sudo yum -y update

Once the update has been done, reboot your system.

sudo systemctl reboot

Wait for reboot to be completed then login back and continue with the installation of Docker CE on Amazon Linux 2.

1. Install Docker Dependencies

Install the basic dependencies required for running Docker on Amazon Linux 2023.

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

If running on actual AWS Cloud and not Developer machine install other tools that ensure integration with other AWS services is seemless.

sudo yum -y install curl wget git unzip awscli aws-cfn-bootstrap nfs-utils chrony conntrack jq ec2-instance-connect socat

If the ec2-net-utils package is installed remove it as it interferes with the route setup on the instance.

if yum list installed | grep ec2-net-utils; then sudo yum remove ec2-net-utils -y -q; fi

Set correct system timezone and Clock.

sudo yum -y install chrony
sudo systemctl enable --now chronyd
sudo timedatectl set-timezone Africa/Nairobi

Sync NTP time.

$ sudo chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- time.cloudflare.com           3   6   377   108  +6017us[+5511us] +/-   79ms
^- time.cloudflare.com           3   6   377    46  +5681us[+5274us] +/-   79ms
^- ntp3.inx.net.za               2   6   377    41  -1956us[-1956us] +/-   68ms
^+ 160.119.216.197               2   6   377    40  -2804us[-2804us] +/-   19ms
^+ 160.119.216.206               2   6   377     6  -1890us[-1890us] +/-   17ms
^- ke-nbo-rs02b.dpogroup.com     2   6   377    55    -10ms[  -10ms] +/-   88ms
^* 160.119.216.202               2   6   377    43   +898us[ +490us] +/-   18ms
^+ 41.175.51.165                 2   6    37    45  -1878us[-2285us] +/-   47ms
^- za-ctn-rs01a.dpogroup.com     2   6   377    40  -4686us[-4686us] +/-   85ms
^- ns1.iway.na                   2   6   377    50    -11ms[  -11ms] +/-  169ms

2. Add the Official Docker CE repository

Docker maintains its own upstream repo for RPM-based distros (RHEL, Rocky, Alma, etc.) and AL2023 is compatible with the RHEL9 packages. Add the following repo file to your AL2023 server:

sudo tee /etc/yum.repos.d/docker-ce.repo > /dev/null <<'EOF'
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/rhel/9/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/rhel/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/rhel/9/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/rhel/gpg
EOF

Then confirm the repo:

$ sudo yum repolist
repo id                                                                                        repo name
amazonlinux                                                                                    Amazon Linux 2023 repository
docker-ce-stable                                                                               Docker CE Stable - x86_64
kernel-livepatch                                                                               Amazon Linux 2023 Kernel Livepatch repository

2. Install Docker Packages on Amazon Linux 2023

With the dependencies installed we can now install Docker packages on Amazon Linux 2023.

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.

This command installs Docker, but it doesn’t start Docker. It also creates a docker group, however, it doesn’t add any users to the group by default.

To add your user to the docker group.

sudo usermod -aG docker $USER
newgrp docker

Create Docker json configuration file.

Start and enable docker service.

sudo systemctl daemon-reload
sudo systemctl enable --now docker

Confirm Docker service status shows as running.

3. Test Docker Installation on Amazon Linux 2023

Now that Docker has been installed on Amazon Linux 2023 machine, let’s try pull a test image. Remember we added our user to docker group which means we should be able to run docker commands without sudo.

$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
17eec7bbc9d7: Pull complete
Digest: sha256:f7931603f70e13dbd844253370742c4fc4202d290c80442b2e68706d8f33ce26
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

Run the image.

$ docker run --rm hello-world

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.
    (amd64)
 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.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Our next tutorial will cover the installation and usage of Docker Compose on Amazon Linux. In the meantime check other guides we have on Amazon Linux.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Unlock the Right Solutions with Confidence

At CloudSpinx, we don’t just offer services - we deliver clarity, direction, and results. Whether you're navigating cloud adoption, scaling infrastructure, or solving DevOps challenges, our seasoned experts help you make smart, strategic decisions with total confidence. Let us turn complexity into opportunity and bring your vision to life.

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

Upgrading the Fedora system from one release version to the next release version is a very important process that is […]

Amazon Linux 2023 (AL2023) is the newest version of Amazon Linux distribution designed to provide a secure and stable high-performance […]

To expose ArgoCD on a self-managed Kubernetes cluster, there needs to be a way to provide the application with an […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.