Install Docker on Ubuntu 26.04 the right way. Production-tested commands, security checklists, and post-deployment optimizations. Perfect for DevOps teams. Start deploying containers now. #Docker #Ubuntu #CentLinux
Table of Contents
Introduction
As a seasoned infrastructure engineer holding certifications including RHCE, CKA, ISC2 CC, and AWS certifications, I’ve witnessed the evolution of containerization from its early days to becoming the backbone of modern application deployment. Docker, despite the emergence of alternatives like Podman and containerd, remains a critical tool in any engineer’s arsenal.
Today, I’ll walk you through installing Docker on Ubuntu 26.04, sharing insights gained from years of production experience across enterprise environments. While the commands might seem straightforward, I’ll provide the context and best practices that separate a reliable deployment from a problematic one.

Prerequisites
Before we begin, ensure you have:
- Ubuntu 26.04 LTS (or a recent version) with root/sudo access
- A stable internet connection
- Basic familiarity with the Linux command line
Install Docker on Ubuntu 26.04: Complete Process
Step 1: System Update and Preparation
sudo su -The Expert’s Take: I always recommend performing installations under a root shell when dealing with system-level changes. While I typically advocate for using sudo with individual commands, the su - approach ensures environment variables and PATH settings are properly inherited, preventing unexpected permission issues. Just remember to exit when finished to return to your regular user context.
apt update -y
apt upgrade -yWhat This Does: Updates your package index and upgrades all installed packages to their latest versions. The -y flag automatically answers “yes” to prompts.
Pro Tip: In production environments, I recommend scheduling system upgrades during maintenance windows. Ubuntu 26.04’s package management has improved significantly, but I’ve seen enough dependency issues to warrant caution. Always review what’s being upgraded, especially kernel packages that might require a reboot.
Step 2: Install SSH Server
apt install ssh -y
systemctl enable --now sshdWhy SSH First: This might seem odd in a Docker installation guide, but as someone who’s managed thousands of servers, I always ensure I have remote access before proceeding with other installations. If something goes wrong with Docker installation, SSH access ensures you can recover the system remotely.
Best Practice: After installation, consider hardening your SSH configuration. Edit /etc/ssh/sshd_config to disable root login, use key-based authentication, and change the default port if your security policy requires it.
Step 3: Install Docker Prerequisites
apt install ca-certificates curl -yExplanation: These packages are essential for secure repository access:
ca-certificates: Ensures your system trusts SSL certificatescurl: Used to download the Docker GPG key
Security Note: I’ve seen organizations neglect to keep CA certificates updated, leading to mysterious SSL errors. This is particularly important in corporate environments with proxy servers or internal certificate authorities.
Step 4: Setup Docker Repository
This is where things get interesting. Docker has evolved their repository setup significantly over the years.
install -m 0755 -d /etc/apt/keyringsWhat This Does: Creates the directory for storing GPG keys with proper permissions (0755 means read/execute for all, write for root only). This follows the Filesystem Hierarchy Standard and improves security by keeping keys in a dedicated directory.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.ascSecurity Critical: I always verify GPG keys manually when possible. While the -fsSL flags handle errors silently, I’d recommend adding -v for verbose output in scripts you’re testing. The chmod a+r ensures all users can read the key, which is necessary for APT to verify packages.
Expert Opinion: This new GPG key location (/etc/apt/keyrings/) is a welcome change from the old /usr/share/keyrings approach. It’s cleaner and follows modern Linux conventions. I’ve had to migrate many legacy systems from the old apt-key method, which was deprecated for good reason – it was too permissive.
tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOFBreaking This Down: This creates the repository configuration file using the new DEB822 format. Key points:
Types: debspecifies it’s a binary package repository- The
Suitesline automatically detects your Ubuntu version Architecturesdetects whether you’re on 64-bit (amd64) or ARMSigned-Bypoints to the GPG key we downloaded
Experience Insight: The automatic detection of Ubuntu codename and architecture is a lifesaver. I’ve seen too many installation scripts hardcode these values, leading to failures when running on different systems. This approach is robust and maintainable.
Step 5: Install Docker Components
apt update -y
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -yWhat Each Package Does:
docker-ce: The Docker daemon (core engine)docker-ce-cli: Command-line interfacecontainerd.io: Container runtime (industry standard)docker-buildx-plugin: Extended build capabilities with BuildKitdocker-compose-plugin: The official Docker Compose plugin
Important Note: The package names have evolved. docker.io is the Ubuntu-provided version (often outdated), while docker-ce is the official Docker Community Edition. Always use the official packages for production.
My Take on the Components:
- containerd.io is now the recommended runtime. While older guides might suggest other runtimes, containerd is what Docker uses internally and has proven production-ready.
- docker-buildx-plugin is essential for modern builds. It supports multi-platform builds and better caching.
- docker-compose-plugin being integrated as a plugin (instead of a separate binary) is much cleaner and avoids version conflicts.
Step 6: Start and Verify Docker
systemctl enable --now dockerWhat This Does: Enables Docker to start automatically at boot and starts it immediately. The --now flag combines enable and start.
Verification:
docker versionWhat You Should See: Client and server version information. If you see both, you’ve successfully installed Docker.
Pro Tip: After installation, always run:
docker run hello-worldThis validates that Docker can pull and run containers properly. It’s a simple test that catches networking, DNS, and permission issues.
Post-Installation Best Practices
1. User Management
Rather than running Docker as root, add your user to the docker group:
usermod -aG docker $USER
newgrp dockerSecurity Warning: This gives users in the docker group root-equivalent access. Use this carefully in multi-user environments.
2. Configure Docker Daemon
Create /etc/docker/daemon.json with sensible defaults:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"storage-driver": "overlay2"
}Experience Insight: Log configuration is crucial. I’ve seen production systems crash because Docker logs consumed all disk space. The overlay2 storage driver is now stable and offers better performance.
3. Set Up Regular Updates
Create a cron job for security updates:
0 2 * * * apt update && apt upgrade -y docker-ce docker-ce-cli containerd.ioTroubleshooting Common Issues
Permission Denied
If you get “permission denied” when running docker commands:
- Check if you’re in the docker group
- Log out and back in for group changes to take effect
Repository Issues
If apt update fails:
- Verify the GPG key is correctly placed
- Check network connectivity to download.docker.com
- Confirm
/etc/apt/sources.list.d/docker.sourceshas the correct format
Security Considerations
As someone holding security certifications, I must emphasize:
- Regular Updates: Docker publishes security patches frequently. Keep your installation updated.
- Image Security: Use trusted images from Docker Hub or your private registry. Scan images for vulnerabilities.
- Network Security: By default, Docker allows container-to-host communication. Consider implementing firewall rules.
- Audit Logging: Enable Docker daemon logging and consider tools like Falco for runtime security.
Conclusion
Installing Docker on Ubuntu 26.04 has become remarkably straightforward. The improved repository setup and integrated plugin system show Docker’s maturity. However, proper installation is just the beginning of a successful containerization journey.
Remember, as an engineer with years of experience, I’ve learned that the best systems are those where installation procedures are well-documented, security is baked in from the start, and maintenance is automated. Use this guide as a foundation, but adapt it to your specific security policies and operational requirements.
Additional Resources
Bonus: Download the Ansible Playbook
Automate your Docker deployment across multiple servers with our production-tested Ansible playbook. Save time, ensure consistency, and eliminate manual errors.
⬇️ Download install-docker.yaml
Frequently Asked Questions (FAQs)
1. Which Docker package should I install?
Question: “What’s the difference between docker.io, docker-ce, and docker-engine?”
Answer: Install docker-ce (Community Edition) from Docker’s official repository. docker.io is Ubuntu’s outdated package, and docker-engine is deprecated. The official Docker CE provides the latest features, security updates, and stable performance for production environments.
2. Do I need to reboot after installing Docker?
Question: “Is a system reboot required after Docker installation?”
Answer: Not typically. Docker runs as a user-space service and doesn’t require a reboot. However, if your system upgraded the Linux kernel during apt upgrade, you should reboot. Check with [ -f /var/run/reboot-required ] && echo "Reboot needed". If not, you can start using Docker immediately.
3. Why do I get “permission denied” with Docker commands?
Question: “I installed Docker as root, but my regular user can’t run docker commands.”
Answer: Add your user to the docker group: sudo usermod -aG docker $USER. Then log out and back in for changes to take effect. Security note: Users in the docker group have root-equivalent privileges, so only add trusted users.
4. How do I completely uninstall Docker?
Question: “What’s the proper way to remove Docker and all its data?”
Answer:
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt autoremove --purge
sudo rm -rf /var/lib/docker /var/lib/containerd /etc/docker
sudo rm /etc/apt/sources.list.d/docker.sources /etc/apt/keyrings/docker.asc⚠️ Warning: This permanently deletes all containers, images, volumes, and configurations.
5. Is Docker production-ready with default settings?
Question: “Can I use the default Docker configuration in production?”
Answer: No. You must configure log rotation, storage driver optimization, and security settings first. Minimum production configuration:
{
"log-driver": "json-file",
"log-opts": {"max-size": "10m", "max-file": "3"},
"storage-driver": "overlay2"
}Also restrict container privileges, implement firewall rules, and use trusted images only.
Recommended Courses
If you’re serious about mastering modern containerization and orchestration, Docker and Kubernetes: The Complete Guide by Stephen Grider is a must-have course. Designed for beginners and professionals alike, it walks you step-by-step through building, deploying, and scaling applications with Docker and Kubernetes—the two most in-demand technologies in DevOps today. With practical projects and expert explanations, this course can fast-track your skills and career growth.
Disclaimer: This link is an affiliate link, and I may earn a small commission at no extra cost to you if you decide to enroll through it.








Leave a Reply
You must be logged in to post a comment.