A sleek laptop and smartphone placed on wooden flooring, showcasing contemporary technology.

How to Install Docker on Ubuntu 24.04

Docker is a powerful platform for developers and system administrators to build, ship, and run applications in containers. In this guide, we’ll walk you through the steps to install Docker on Ubuntu 24.04. By the end, you’ll have a functional Docker setup ready for your containerized projects.

Prerequisites

Before you begin, ensure you have the following:

  1. An Ubuntu 24.04 system. You can use the Desktop or Server edition. Both versions will work.
  2. A user account with sudo privileges.
  3. Internet access for downloading packages.

Step 1: Update Your System

Start by updating the package index on your system. Open a terminal and run:

sudo apt update && sudo apt upgrade -y

This ensures that all packages are up-to-date, which is important for a smooth Docker installation.

Step 2: Install Required Dependencies

Docker requires some additional packages to function properly. Install these by running:

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

Step 3: Add Docker’s Official GPG Key

To verify the authenticity of the Docker packages, you need to add Docker’s GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Step 4: Add Docker’s Repository

Next, set up the stable Docker repository on your system:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.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

Update the package index again and install Docker Engine:

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

Step 6: Verify the Installation

Check if Docker is installed and running correctly by checking the version:

docker --version

You should see the Docker version displayed. Additionally, verify the Docker service is active:

sudo systemctl status docker

Step 7: Manage Docker as a Non-root User (Optional)

By default, Docker requires root privileges. To run Docker as a non-root user, add your user to the Docker group:

sudo usermod -aG docker $USER

Log out and back in for the changes to take effect. Test it by running:

docker run hello-world

If successful, you’ll see a message indicating Docker is installed and working.

Conclusion

Congratulations! You’ve successfully installed Docker on Ubuntu 24.04. You can now start creating and managing containers to streamline your development workflow. For more advanced Docker usage, consider exploring Docker Compose and Kubernetes.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

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