2. How to Install Docker on Ubuntu 24.04

Docker is a popular containerization platform that simplifies application deployment by packaging applications and their dependencies into portable containers. This guide provides a step-by-step approach to installing Docker on Ubuntu 24.04, focusing on both implementation and the reasoning behind each step.
Why Use Docker?
Docker provides:
Consistent environments across different systems.
Lightweight, isolated containers for applications.
Simplified deployment and scalability.
Installing Docker on Ubuntu 24.04
Follow these steps to install and configure Docker properly:
Step 1: Install Docker Using Snap
Docker is available as a Snap package, making installation quick and straightforward:
sudo snap install docker
Snap ensures automatic updates and a secure installation process.
Step 2: Create the Docker Group
By default, Docker requires sudo
to run. Creating a docker
group allows non-root users to manage containers without sudo
:
sudo groupadd docker
Step 3: Add Your User to the Docker Group
Grant your user access to Docker by adding it to the docker
group (replace username
with your actual username). So if the username is “arun” then simply run sudo usermod -aG docker arun
:
sudo usermod -aG docker <username>
This prevents the need for sudo
when running Docker commands.
Step 4: Apply the New Group Membership
Apply the updated group permissions without logging out:
newgrp docker
Alternatively, logging out and back in ensures the changes take effect.
Step 5: Fix Docker Socket Permissions
Ensure the Docker socket (/var/run/docker.sock
) has the correct ownership:
sudo chown root:docker /var/run/docker.sock
This step allows the docker
group to access Docker’s communication socket.
Step 6: Verify the Installation
Check if Docker is installed correctly by listing running containers:
docker ps
If no error occurs, Docker is set up correctly, and you can start using it without sudo
.
Conclusion
With Docker installed, you can now create and manage containers efficiently. Consider exploring Docker Compose for multi-container applications or configuring persistent storage for data management. This setup ensures a smooth development workflow with minimal overhead.
Subscribe to my newsletter
Read articles from Adarsh Bhaskar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Adarsh Bhaskar
Adarsh Bhaskar
Hi there! I’m Adarsh, a passionate information science student with hands-on experience in machine learning, software development, and data analysis. I thrive on solving complex problems and enjoy collaborating with teams to bring innovative solutions to life. Whether it’s developing a recommendation engine or streamlining workflows with automation, I love diving into new technologies. I’m always eager to learn and explore fresh ideas, especially in the world of Flutter app development!