Why Isn't It Just sudo apt install docker?

If you're like me, you might’ve tried installing Docker on your Ubuntu machine by typing sudo apt install docker
, only to end up with something unexpected or worse, confused about why it didn’t work. I know I did. The command seems straightforward enough, right? But here’s the kicker: it’s not just that simple.
In this post, we’ll explore why sudo apt install docker
doesn’t always give you what you expect, how to properly install Docker Engine (or Docker Desktop), and why security considerations like user permissions matter. Whether you're setting up a dev environment or prepping for production, understanding these nuances will save you time and frustration down the line.
What Is “Why It’s Not Just sudo apt install docker
”?
Let’s start with the basics. When people say "just run sudo apt install docker
", they’re often oversimplifying. Why? Because the default Ubuntu repositories include an older, community-maintained version of Docker called docker.io, which is not the same as Docker Engine or Docker Desktop from Docker Inc.
So what happens if you go ahead and install it anyway?
- You get a very basic version of Docker that may lack features.
- It might be outdated compared to the latest stable release.
- You miss out on Docker Compose, containerd, and other essential components unless manually added.
That’s why most developers and system admins prefer installing Docker using the official Docker repository ensuring compatibility, access to the latest features, and better integration with modern workflows.
Why Is It Important to Do It Right?
You might be thinking, "I’m just running a few containers locally. Does it really matter?" Well, yes and here’s why:
1. Avoid Confusion with Legacy Packages
As mentioned earlier, there’s already a package named docker
in the Debian/Ubuntu repos that refers to an unrelated utility. Installing it without checking can lead to confusion, especially when commands don’t behave as expected.
2. Security Best Practices
Running Docker with sudo
every time isn’t ideal. In fact, it’s a potential security risk. Best practice is to create a docker
group and add your user to it, allowing non-root execution of Docker commands.
3. Access to Modern Features
Installing via the official repo ensures you get support for Docker Compose, BuildKit, image scanning, and more all critical for development and CI/CD pipelines.
How to Install Docker Properly on Ubuntu
Here’s a quick guide to installing the official Docker Engine on Ubuntu, avoiding the pitfalls of sudo apt install docker
.
Step-by-Step Installation Guide
Add your user to the docker
group
sudo usermod -aG docker $USER
Then log out and back in for changes to take effect.
Install Docker Engine
sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Set up the repository
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
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
Install required packages
sudo apt update && sudo apt install ca-certificates curl gnupg
Remove any old versions
sudo apt remove docker docker-engine docker.io containerd runc
Benefits of Doing It Right
Now that you’ve installed Docker the proper way, let’s talk about the benefits:
- ✅ Up-to-date versions: Get the latest Docker releases directly from Docker Inc.
- ✅ Better tooling: Includes Docker Compose, BuildKit, and containerd by default.
- ✅ Improved security: Avoid unnecessary use of
sudo
by managing access via groups. - ✅ Compatibility: Works seamlessly with cloud providers, Kubernetes, and CI tools like GitHub Actions and GitLab CI.
And perhaps most importantly, you avoid the headache of debugging issues caused by outdated or incomplete installations.
Conclusion
So next time someone says, “Just run sudo apt install docker
,” you’ll know better. Taking the extra steps to install Docker from the official repo pays off in performance, security, and flexibility especially as your projects grow more complex.
Ready to try it yourself? Follow the steps above and leave a comment below sharing your experience! If you found this helpful, consider subscribing for more tips on Linux utilities, AI tools, programming, and all things DevOps.
Happy containerizing 🐳!