As a seasoned DevOps engineer and Docker power user, I can‘t emphasize enough how important it is to have Docker installed and running smoothly. Containerization through Docker has become an essential part of the development workflow. This comprehensive guide will walk you through installing Docker on the most common operating systems – Ubuntu, CentOS, Debian, and Windows.
Whether you‘re looking to set up Docker for a personal project or for enterprise-scale deployment, this step-by-step guide has got you covered. I‘ll provide my own experiences and tips I‘ve learned from installing Docker countless times over the years. Let‘s get started!
Why Docker?
Before jumping into the installation, I want to provide some high-level context on why Docker is so valuable in the first place. Docker enables you to package applications into standardized units called containers. This provides a ton of benefits:
- Portability – Containerized apps can run on any OS without compatibility issues
- Speed – Containers start almost instantly since they share the host OS
- Efficiency – Containers are lightweight and only hold necessary components
- Isolation – Apps run safely isolated within containers
- Scalability – It‘s easy to scale apps by running more container instances
- Collaboration – Share and use containers from a registry like Docker Hub
According to Docker‘s 2021 survey, 87% of organizations are now using containers in production. And for good reason – I‘ve personally seen Docker improve deployment velocity, app portability and developer productivity time and time again.
Now let‘s look at how to get Docker up and running on various systems.
Installing Docker on Ubuntu
Ubuntu is one of the most popular Linux distributions, making it a great choice for running Dockerized apps in production.
Based on my experience, here are some key tips for a smooth Docker install on Ubuntu:
- Use the official Docker repositories instead of Ubuntu‘s – this ensures you get the latest Docker version which is critical.
- Add the GPG key and repository before installing – this validates the integrity of the Docker packages.
- Always install the latest stable Docker release – this takes advantage of the newest features and security fixes.
- Use the convenience script for adding the repo if available – e.g. the Ubuntu install script.
- Stick to LTS versions like 18.04/20.04 for stability.
Now let‘s walk through the installation steps.
Prerequisites
- Ubuntu 18.04 or 20.04 (LTS versions recommended)
- Non-root user account with sudo privileges
First, update your package index:
sudo apt update
Install the pre-requisite packages that allow apt to use HTTPS repositories:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Then add the GPG key from Docker to validate package integrity:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
I recommend using the convenience script to add Docker‘s repository:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
This automatically adds the repository and installs the latest stable release.
Alternatively, you can manually add the repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Next, update the package database:
sudo apt update
Verify you are installing from the official Docker repository:
apt-cache policy docker-ce
Finally, install Docker:
sudo apt install docker-ce
Docker should now be installed and running! Verify with:
sudo systemctl status docker
And Docker is ready to use on your Ubuntu system.
Installing Docker on CentOS
CentOS is the free community version of Red Hat Enterprise Linux (RHEL). It‘s popular for enterprise production environments.
For a successful Docker install on CentOS, be sure to:
- Use the official Docker repository instead of CentOS‘ – this guarantees the latest version.
- Install Docker from the repository, don‘t attempt manual installation.
- Stick to CentOS 7 minimal for a stable base image to build on top of.
- Remove any old Docker packages before installing new versions.
Now let‘s go through the installation:
Prerequisites
- CentOS 7 minimal
- Root access or sudo user
First, update your package index:
sudo yum update
Next, install the Docker repository:
curl -fsSL https://get.docker.com/ | sh
This automatically adds the repository and installs the latest Docker release.
Alternatively, you can manually add the repo:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Once the repository is added, install Docker:
sudo yum install docker-ce
Start and enable Docker to run on startup:
sudo systemctl start docker
sudo systemctl enable docker
Verify it‘s installed and running:
sudo systemctl status docker
Docker is now ready to use on CentOS!
Installing Docker on Debian
Debian is a very flexible and stable Linux distribution based on FreeBSD. Here are some tips for deploying Docker:
- Use the official Docker Debian repository to get the latest version.
- Make sure to install curl/HTTPS transport utilities before adding the repo.
- I recommend Debian 10 Buster for the best compatibility with latest Docker.
- Remove any old Docker packages before installing new ones.
Okay, let‘s install Docker on Debian:
Prerequisites
- Debian 10 Buster
- Non-root user with sudo access
First, update your package list:
sudo apt update
Install curl, HTTPS transport, and GPG:
sudo apt install curl gnupg2 ca-certificates software-properties-common apt-transport-https
Next, add Docker‘s GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Then add Docker‘s repository to your sources list:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
Update your package list from the new repo:
sudo apt update
Verify you‘ll install from the Docker repository:
apt-cache policy docker-ce
Finally, install Docker:
sudo apt install docker-ce
Docker should now be installed and running! Test with:
sudo systemctl status docker
That‘s it for installing Docker on Debian, one of my favorite Linux distros.
Installing Docker on Windows
You can also install Docker on 64-bit Windows 10 Pro, Enterprise, or Education editions.
For the best experience, I recommend:
- Using Windows 10 Pro/Enterprise for full feature support
- Installing the latest Windows updates
- Enabling Hyper-V and Containers features
- Using PowerShell for the installation steps
Let‘s go through it:
Prerequisites
- Windows 10 Pro/Enterprise 64-bit
- Windows Server 2019
- Administrator account
- PowerShell
First, install the Docker Microsoft PackageManagement provider:
Install-Module DockerMsftProvider -Force
Next, install the Docker package:
Install-Package Docker -ProviderName DockerMsftProvider -Force
Once it finishes, reboot your machine to complete the installation.
Verify Docker is installed and check the version:
docker version
Take it for a test drive with a sample container:
docker run hello-world
And that‘s it for installing Docker on Windows! You now have a production-grade Docker environment on Windows.
Closing Thoughts
In this comprehensive guide, I covered Docker installation best practices and step-by-step instructions for Ubuntu, CentOS, Debian and Windows. The examples provided should give you a smooth Docker install on your system of choice.
While the installation steps will vary across different environments, the general approach remains the same – use official repos, latest versions, and validate with Docker‘s test containers.
With Docker running properly, you‘re now ready start building and deploying your own containerized applications! Be sure to take advantage of resources like Docker Hub for sharing containers publicly or privately.
For further learning, I highly recommend Docker‘s official documentation and training resources. Let me know if you have any other Docker-related topics you‘d like me to cover in a future post!