Docker is a containerization platform that allows developers to build, deploy, and run applications in isolated containers. In this guide, we'll walk through the process of installing Docker on Ubuntu 24.04.
Step 1: Update the System
Before installing Docker, it's recommended to update your system's packages. Open a terminal and run the following commands:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Packages
To install Docker, you'll need some packages that ensure Docker operates correctly. Run the following command to install these packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Step 3: Add Docker Repository
Next, add Docker's official repository. First, add the GPG key for the repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Then, add Docker's repository to your APT sources:
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 4: Install Docker
With the Docker repository added, update your package list and install Docker:
sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io -y
Step 5: Verify Docker Installation
After installing Docker, ensure that it is installed and running properly:
sudo systemctl status docker
You should see output indicating that the Docker service is active and running.
Step 6: Add User to Docker Group
To run Docker commands without sudo
, add your user to the Docker group:
sudo usermod -aG docker $USER
To apply the changes, either log out and log back in, or run:
newgrp docker
Step 7: Test Docker
Now, check if Docker is working correctly by running a test container:
docker run hello-world
If the installation was successful, you will see a message from Docker confirming that it is working correctly.
Congratulations! You've successfully installed Docker on your Ubuntu 24.04 server. You can now use Docker for containerization and deploying your applications. If you encounter any issues or have questions, the Docker official documentation and community are always available to help.