Skip to content
Home » My Blog Tutorial » How to Install Docker on Ubuntu 24.04

How to Install Docker on Ubuntu 24.04

Docker Logo

How to Install Docker on Ubuntu 24.04: A Step-by-Step Guide

Docker is a powerful platform for containerizing applications, ensuring they run seamlessly across different environments. In this guide, we’ll walk you through the steps to install Docker on Ubuntu 24.04, so you can start leveraging the benefits of containerization in no time.

Step 1: Update Operating System

First things first, let’s make sure your Ubuntu 24.04 system is up-to-date. Open your terminal and run:

sudo apt update && sudo apt upgrade

This ensures all existing packages are current, laying a stable foundation for the Docker installation.

Step 2: Install Dependencies

Next, you’ll need to install some necessary packages that allow Ubuntu to access Docker repositories over HTTPS. Use the following command:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

These dependencies are crucial for the secure download and installation of Docker.

Step 3: Add Docker GPG Key

Now, add Docker’s official GPG key to your system. This key is used to verify the authenticity of the Docker packages:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step 4: Add Docker Repository

To install Docker, you need to add its repository to APT sources. Run:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

This command adds the Docker repository, enabling you to download Docker packages from it.

Step 5: Install Docker

With the repository added, you’re now ready to install Docker. Execute the following command:

sudo apt install docker-ce

After the installation is complete, verify the installed Docker version with:

docker --version

You should see an output similar to:

Docker version 26.0.0, build 2ae903e

Step 6: Check Docker Service Status

Ensure that the Docker service is running:

sudo systemctl status docker

You should see output indicating that the Docker service is active and running. To make sure Docker starts on boot, enable it with:

sudo systemctl enable docker

Step 7: Test Docker Installation

Run a test Docker container to confirm everything is working correctly:

sudo docker run hello-world

This command pulls a test image from Docker Hub and runs it. If successful, you’ll see a “Hello from Docker!” message.

Step 8: Using Docker Commands

To list only active containers, use:

sudo docker ps

To list all containers, including inactive ones, add the -a flag:

sudo docker ps -a

Starting a stopped container:

sudo docker start [container-ID | container-name]

Stopping a running container:

sudo docker stop [container-ID | container-name]

Removing an unnecessary container:

sudo docker rm [container-ID | container-name]

To view all Docker subcommands, just type:

docker

Step 9: Run Docker without Sudo

If you’d like to run Docker commands without needing sudo, add your user to the Docker group:

sudo usermod -aG docker $USER

Replace $USER with your actual username. Then, restart your system for the changes to take effect.

Wrapping Up

Congratulations! You’ve successfully installed Docker on your Ubuntu 24.04 system. Now you can start creating, deploying, and managing containers effortlessly. For additional resources, check out the official Docker documentation.

If you have any questions or run into issues, feel free to leave a comment below. Happy containerizing!


Discover more from teguhteja.id

Subscribe to get the latest posts sent to your email.

Tags:
Optimized by Optimole
WP Twitter Auto Publish Powered By : XYZScripts.com

Discover more from teguhteja.id

Subscribe now to keep reading and get access to the full archive.

Continue reading