Install and Use Docker On Ubuntu 24.04 (Noble Numbat)

Docker is a platform for building, deploying, and shipping containerized applications. A container packages an application with all its dependencies and configurations and is isolated from all other processes on the host machine. Containers are portable and can easily be shared and moved around. This way, developers can develop and deploy applications efficiently. Containers live in a container repository which acts as special storage for containers. They are accessed as either public or private repositories. Thus a container:-

  • Is a running instance of an image. It can be created, started, stopped, moved, deleted, etc.
  • Can run on local machines, VMs, and in Cloud.
  • Is portable and easy to use.
  • Is isolated from other containers and runs its own software, binaries, and configurations.

Docker hub is a public repository that contains multiple applications images hosted in the repository. Docker makes the development process faster, easy, and more portable. So if you are a developer looking for a platform to build, share and run applications faster and easily, docker will do that for you.

Docker employs the idea of microservices. Microservices structures applications as a collection of multiple services that are highly maintainable, loosely coupled, and independently deployed. The key advantage of microservices architecture is that they enable fast, frequent, and reliable delivery of large, complex applications.

Docker Capabilities

As a developer, why would you choose Docker over other platforms?

  • Build – There are hundreds of Docker images available for selection. This makes the build process very fast. in addition, you can build multiple containers using Docker Compose. Developers prefer Docker because it easily integrates with their favorite build tools e.g VS Code, CircleCI, and GitHub. Because of its portability, the developers can package their applications to run in any environment e.g on-premises, Kubernetes, AWS ECS, Azure ACI, Google GKE, etc.
  • Share – Docker allows developers to collaborate with one another by publishing their images to Docker Hub.
  • Run – Docker makes it possible to run multiple applications the same way across all environments. It also ensures that applications are deployed in separate containers independently using different languages. Docker Compose CLI speeds up and simplifies application development making the launching of the applications locally and on the cloud with AWS ECS and Azure ACI very fast.

Install Docker CE on Ubuntu 24.04 (Noble Numbat)

To install Docker on your system, the following requirements must be met.

  • 64-bit version of Ubuntu 24.04.
  • sudo account
  • stable internet connection
  • x86_64, arm64, s390x, armhf, and amd64 architectures.

Let’s now install Docker CE on Ubuntu.

Step 1: Update System

Update the APT index before installation.

sudo apt update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f

Once you have updated your system, Uninstall old versions of Docker from your system.

sudo apt remove docker docker-engine docker.io containerd runc

Step 2: Install required dependencies

To successfully install Docker Engine on your host machine, certain basic dependencies need to be installed.

Run the command below to install the dependencies.

sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Step 3: Add Docker’s official GPG key

Import the Docker repository GPG key by running the following command.

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

The command above can also be run as below to use a trusted GPG key.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-archive-keyring.gpg

Step 4: Setup Docker repository

Once the GPG Key has been imported into your Ubuntu system, you now need to set up the Docker CE repository. Run the command below.

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5: Install Docker Engine

It’s all systems go. At this point, the environment is ready to install Docker CE on Ubuntu. Execute the following command.

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -y

The command executes to install Docker Engine on your Ubuntu system. If you wish to install a specific version of Docker Engine, begin by listing all the available versions and then select your preferred version for installation. Run the command below:

apt-cache madison docker-ce

To install a specific version use the syntax below.

sudo apt install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin

To check the Docker Version installed, run the command:

$ docker --version
Docker version x.y.z, build bc4487a

To see a list of Docker options and commands:

docker --help

Step 6: Add user account to docker group

It’s always advisable to run docker commands without root privileges. This can be achieved by adding the normal user to the docker group created by default during Docker Engine installation.

List all groups by :

$ cat /etc/group
## Sample output ##
jil:x:1000:
sambashare:x:135:jil
rdma:x:136:
docker:x:999:

To add the system user to the docker group, run the following commands.

sudo usermod -aG docker $USER
newgrp docker

Step 7: Running Docker services

To start using your Docker Engine, you need to start and enable the docker services to be available on every boot.

Start the service by the command:

sudo systemctl start docker

Enable Docker to run on the next boot.

sudo systemctl enable docker

Check the Docker Engine status:

$ systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
     Active: active (running) since Sun 2024-10-02 19:27:59 EAT; 29min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 35790 (dockerd)
      Tasks: 13
     Memory: 23.0M
        CPU: 399ms
     CGroup: /system.slice/docker.service
             └─35790 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/con>

Okt 30 19:27:58 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:58.8863797>
Okt 30 19:27:58 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:58.8864881>
Okt 30 19:27:58 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:58.8865737>
Okt 30 19:27:58 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:58.9434742>
Okt 30 19:27:59 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:59.1257844>
Okt 30 19:27:59 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:59.2117554>
Okt 30 19:27:59 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:59.2328453>
Okt 30 19:27:59 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:59.2330105>
Okt 30 19:27:59 ubuntu-22-lab systemd[1]: Started Docker Application Container >
Okt 30 19:27:59 ubuntu-22-lab dockerd[35790]: time="2023-10-02T19:27:59.2586058>

Step 8: Run a sample docker container

For demonstration purposes, I will spin the Nginx container image on Docker. Issue the command.

$ docker run --name testnginx -p 80:80 -d nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
31b3f1ad4ce1: Pull complete 
fd42b079d0f8: Pull complete 
30585fbbebc6: Pull complete 
18f4ffdd25f4: Pull complete 
9dc932c8fba2: Pull complete 
600c24b8ba39: Pull complete 
Digest: sha256:0b970013351304af46f322da1263516b188318682b2ab1091862497591189ff1
Status: Downloaded newer image for nginx:latest
69d4bf6043924f13f60a361f42873cef4a9a55711a4e966c6e3ec8ee736dfd5a

testnginx is the name of the created container based on the NGINX image.

  • -d option:  specifies that the container runs in detached mode.
  • -p option: tells Docker to map the ports exposed in the container by the NGINX image (port 80 ) to the specified port on the Docker host. The first parameter specifies the port in the Docker host while the second parameter is mapped to the port exposed in the container.

To verify if the container was created and is running properly, run the command:

$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                               NAMES
69d4bf604392   nginx     "/docker-entrypoint.…"   7 minutes ago   Up 7 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   testnginx

Step 9: Uninstall Docker Engine (reference only)

To uninstall Docker Engine, issue the command below.

 sudo apt purge docker-ce docker-ce-cli containerd.io

The command will completely purge all Docker Engine packages from the system.

To completely delete all images, containers, and volumes:

 sudo rm -rf /var/lib/docker
 sudo rm -rf /var/lib/containerd

I hope the guide was an eye-opener and you have learned something new. Please visit Docker Engine Documentation for more insight.

Explore More with CloudSpinx

Looking to streamline your tech stack? At CloudSpinx, we deliver robust solutions tailored to your needs:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

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

Recent Post

Leave a Comment

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

Related Post

The web browser is the key arsenal that we use to browse the internet. If you want to access information […]

In this guide,we will look at how you can install Java 11 on Oracle Linux 8. Java is a widely […]

The adoption of Containers and microservice architectures has been amazing and speedy in the past few years. Docker is widely […]

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.