UbuntuUbuntu Based

How To Install Docker on Ubuntu 24.04 LTS

Install Docker on Ubuntu 24.04

In this tutorial, we will show you how to install Docker on Ubuntu 24.04 LTS. Docker has revolutionized the way developers and system administrators deploy and manage applications. As a lightweight containerization platform, Docker allows you to package your applications and dependencies into a single, portable unit that can run consistently across different environments. With the release of Ubuntu 24.04, the latest LTS (Long-Term Support) version of the popular Linux distribution, installing Docker has become even more straightforward.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Docker container on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install Docker on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

To begin the Docker installation process, it’s crucial to start with an up-to-date Ubuntu system. Updating your system ensures that you have the latest security patches, bug fixes, and compatible libraries. Open your terminal and run the following command to update the package indexes:

sudo apt update
sudo apt upgrade

This command will fetch the latest package information from the Ubuntu repositories, allowing you to install the most recent version of Docker and its dependencies. Updating the package repository is crucial to maintaining the security and stability of your system.

Step 2. Installing Required Packages.

Next, install the packages necessary for allowing apt to access repositories over HTTPS:

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

Here’s a quick breakdown of what each package does:

  • apt-transport-https: Allows the package manager to transfer files and data over HTTPS.
  • ca-certificates: Enables the system to check security certificates.
  • curl: A tool to transfer data from or to a server.
  • software-properties-common: Adds scripts for managing software.

Step 3. Installing Docker on Ubuntu 24.04.

Securely download and add the GPG key from Docker’s official site to ensure the software you’re installing is authenticated:

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

Adding the GPG key helps prevent the installation of tampered software and ensures the integrity and origin of the software package.

To ensure you receive updates and stable versions of Docker, add the stable repository with the following command:

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

This command configures your system to fetch Docker packages from the official Docker repository, which is recommended over the default Ubuntu repositories for more recent updates.

With the repository set up, you can now proceed to install Docker Engine, the core component of Docker. Run the following command:

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

After the installation is complete, it’s a good practice to verify that the Docker is installed correctly and functioning as expected. Run the following command to test the installation:

sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits. If this succeeds, it confirms that Docker is correctly installed and operational.

Step 4. Post-Installation Steps

By default, running Docker commands requires administrative privileges using sudo. To avoid typing sudo every time you run a Docker command, you can add your user to the Docker group. Execute the following command:

sudo usermod -aG docker ${USER}

This command adds the current user to the docker group. However, for the group changes to take effect, you need to log out and log back in. After logging back in, you can verify that your user is added to the docker group by running:

id -nG

 If you see docker in the output, your user is successfully added to the group.

Step 5. Configure Docker to Start on Boot.

To ensure that Docker starts automatically when your system boots up, you can enable the Docker service using the following command:

sudo systemctl enable docker

This command configures the Docker service to start on system boot, eliminating the need to manually start Docker each time you restart your machine.

Step 6. Advanced Configuration Options.

Docker provides various configuration options to customize its behavior and adapt to specific requirements. One common configuration file is the daemon.json file, located at /etc/docker/daemon.json. This file allows you to configure options such as logging drivers, storage drivers, and network settings.

For example, to change the default logging driver to json-file and set a maximum size for log files, you can create or modify the daemon.json file with the following content:

{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}

After modifying the configuration file, restart the Docker service for the changes to take effect:

sudo systemctl restart docker

It’s important to consult the Docker documentation for a comprehensive list of available configuration options and their usage.

Step 7. Troubleshooting Common Installation Issues.

While the Docker installation process on Ubuntu 24.04 is generally straightforward, you may encounter some common issues. Here are a few troubleshooting tips:

  • If you encounter permission errors when running Docker commands, ensure that your user is added to the docker group as described in Step 7.
  • If you face issues with downloading packages or connecting to repositories, check your internet connection and verify that the required ports (e.g., 443 for HTTPS) are open.
  • If Docker fails to start or you see error messages related to storage drivers, ensure that your system has the necessary kernel modules and storage backends installed.

If you encounter any other issues, the Docker documentation and community forums are excellent resources for finding solutions and troubleshooting steps specific to your situation.

Congratulations! You have successfully installed Docker. Thanks for using this tutorial for installing the Docker container on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Docker website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button