Containerization has revolutionized application deployment and management, offering unparalleled consistency and efficiency. Docker stands at the forefront of this technology, allowing you to package applications into portable containers. Docker Compose, its indispensable companion, simplifies the management of multi-container Docker applications. This guide will walk you through installing both Docker and Docker Compose on your Ubuntu 24.04 system, setting you up for modern development and deployment workflows.
First, it’s good practice to update your package index and install necessary dependencies:
sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release -y
Next, add Docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Now, add the Docker repository to your Apt sources:
echo
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update the package index again to include the new Docker repository:
sudo apt update
Now you can install Docker Engine, Containerd, and Docker Compose:
sudo apt install docker-ce docker-ce-CLI containerd.io docker-buildx-plugin docker-compose-plugin -y
Verify the Docker installation by running the hello-world container:
sudo docker run hello-world
To avoid using sudo every time you run Docker commands, add your user to the docker group:
sudo usermod -aG docker $USER
newgrp docker
Log out and log back in, or simply run newgrp docker to apply the group changes without logging out. After this, you should be able to run Docker commands without sudo. Test it again:
docker run hello-world
You have successfully installed Docker Engine and Docker Compose on your Ubuntu 24.04 system. You are now ready to build, run, and manage your containerized applications efficiently.
