How to Install Docker on Ubuntu, CentOS, Debian and Windows

Docker is an open platform for developing, shipping, and running applications. It enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. This guide provides step-by-step instructions for installing Docker on some of the most popular operating systems.

Introduction to Docker

Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime. These containers guarantee that your application will always run the same, regardless of the environment it is running in.

Some key benefits of Docker include:

  • Portability – You can build locally, deploy to the cloud, and run anywhere.
  • Speed – It improves sysadmin efficiency, developer productivity and end-user happiness.
  • Isolation – Docker containers isolate applications from each other and from the underlying infrastructure.
  • Security – Docker enhances security between containers and hosts with user name spaces and process isolation.

In this guide, you will learn how to install Docker on the following operating systems:

  • Ubuntu
  • CentOS
  • Debian
  • Windows Server

The installation methods covered use the official Docker repositories to ensure you get the latest version. Now let‘s get started!

Installing Docker on Ubuntu

The Ubuntu operating system is a popular choice for Linux-based applications and servers. Here is how to get Docker up and running on it.

Prerequisites

Before installing Docker, you will need:

  • Ubuntu 18.04 or higher
  • Non-root user with sudo privileges

First, update your existing list of packages:

sudo apt update

Then install packages that allow apt to use repositories over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Now add the GPG key from Docker to validate package downloads:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker repository to APT sources:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Update the package database from the new repo:

sudo apt update

Make sure you are installing from the Docker repo:

apt-cache policy docker-ce

Finally, install Docker:

sudo apt install docker-ce

Docker should now be installed, running, and enabled to start on boot automatically. Confirm everything is working with:

sudo systemctl status docker

And that‘s it! Docker is installed on your Ubuntu system.

Installing Docker on CentOS

CentOS is a popular Linux distribution based on Red Hat Enterprise Linux (RHEL). Here is how to get Docker running on CentOS 7.

Prerequisites

You‘ll need:

  • CentOS 7
  • Non-root user with sudo privileges

First, update your system:

sudo yum update

Then add the Docker repository and install the latest version of Docker:

curl -fsSL https://get.docker.com/ | sh

Next, start the Docker daemon:

sudo systemctl start docker 

Check that Docker is running:

sudo systemctl status docker

Now Docker is installed and running on your CentOS system!

Installing Docker on Debian

Debian is another very popular Linux distribution. Here is how to install Docker on Debian.

Prerequisites

You‘ll need:

  • Debian 10
  • Non-root user with sudo privileges

First, update your system‘s package index:

sudo apt update

Install required packages:

sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

Add Docker‘s GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Add Docker repo to APT sources:

echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Update package database:

sudo apt update

Verify you‘ll install from Docker repo:

apt-cache policy docker-ce

Install Docker:

sudo apt install docker-ce

That‘s it! Docker is now installed on your Debian system.

Installing Docker on Windows Server

You can also install Docker on Windows for running Windows containers.

Prerequisites

You‘ll need:

  • Windows Server 2016 or higher

First, install the Docker MsftProvider PowerShell module:

Install-Module DockerMsftProvider -Force 

Next, install the Docker package:

Install-Package Docker -Providername DockerMsftProvider -Force

Once it finishes installing, restart your machine.

Verify Docker is installed and check the version:

docker version

Test Docker is working properly by running a simple Windows container:

docker run mcr.microsoft.com/windows/nanoserver:1809 cmd

And Docker is now up and running on Windows Server!

Getting Started with Docker

With Docker installed on your machine, you‘re ready to start using it!

An easy way to experiment is to run a simple Docker image in a container:

docker run hello-world

This will pull the hello-world Docker image locally and output a test message showing Docker is working correctly.

Some other basic Docker commands include:

docker image ls # List all images
docker container ls # List running containers 
docker stop container_name # Stop a running container

Check out Docker‘s documentation for guides on developing containers, deployment best practices, and more!

Conclusion

In this guide you learned how to get Docker installed on Ubuntu, CentOS, Debian, and Windows Server operating systems. While the steps vary slightly across platforms, the overall process is similar.

Key things to keep in mind:

  • Always use official Docker repositories to ensure latest versions
  • Follow Docker‘s post-installation steps to enable/start services
  • Run test containers and commands to validate Docker works properly

Now that you have Docker ready to go, it‘s time to start building and running your own applications! The key advantage of Docker is helping developers focus on their app code rather than worry about dependencies and environment configuration.

To take your Docker skills even further, refer to these additional resources:

Let me know in the comments if you have any questions on getting Docker up and running!