How to Install Docker and Docker Compose on Ubuntu 24.04
Docker has revolutionized the way developers build, ship, and run applications. By using containers, Docker allows you to package an application with all its dependencies into a standardized unit, which can run consistently on any platform. Docker Compose, on the other hand, simplifies the process of managing multi-container applications, providing a declarative way to define and run complex setups.
This article will guide you through the process of installing Docker and Docker Compose on Ubuntu 24.04 using the Docker Engine installation script.
Prerequisites
Before starting the installation, ensure that your system meets the following prerequisites:
- A system running Ubuntu 24.04: Docker supports only certain versions of Ubuntu, and 24.04 is one of them.
- A user with sudo privileges: Installation and configuration require administrative privileges.
Step 1: Update Your System
Before installing Docker, it’s essential to update your system’s package index. This ensures that you have the latest package information.
sudo apt update
sudo apt upgrade -y
The apt update
command fetches the latest package information from all configured sources. The apt upgrade
command then upgrades all the installed packages to their latest versions. The -y
flag automatically answers “yes” to any prompts during the upgrade process.
Step 2: Download the Docker Installation Script
Docker provides a convenient installation script that automatically configures your package management system and installs Docker. Start by downloading the script:
curl -fsSL https://get.docker.com -o install-docker.sh
Here’s what each part of the command does:
curl -fsSL
: Fetches the script from Docker’s official website.-o install-docker.sh
: Saves the downloaded script asinstall-docker.sh
.
Step 3: Verify the Script’s Content
Before running any script, it’s good practice to review its content to understand what it will do on your system.
cat install-docker.sh
This command displays the content of the script, allowing you to inspect it.
Step 4: Run the Installation Script
Once you are satisfied with the script’s content and dry-run results, proceed with the actual installation. Run the script using sudo
to ensure it has the necessary privileges.
sudo sh install-docker.sh
The script will automatically detect your Linux distribution and version, configure your package management system, and install Docker Engine along with its dependencies.
Step 5: Verify the Docker Installation
After the installation is complete, it’s important to verify that Docker is correctly installed and running.
sudo systemctl status docker
If Docker is running properly, you will see an “active” status. To further confirm that Docker is functioning, you can run a test container:
sudo docker run hello-world
This command pulls a test image from Docker Hub and runs it in a container. If successful, you’ll see a confirmation message from Docker.
Conclusion
In this article, we have walked through the steps to install Docker and Docker Compose on Ubuntu 24.04 using the Docker Engine for Linux installation script. We began by updating the system and downloading the installation script. After verifying the script, we ran it to install Docker, ensuring everything was set up correctly.
By following this guide, you have successfully installed Docker and Docker Compose, providing you with a powerful platform to develop and deploy containerized applications. Remember to explore Docker’s documentation for advanced usage and best practices to get the most out of your Docker environment.
Thank you for reading the article! If you found the information useful, you can donate using the buttons below:
Donate ☕️ with PayPalDonate 💳 with Revolut