Skip to Content

Docker install and upgrade guide - CentOS and Ubuntu

Docker installation - requirements and quick commands cheet sheet!

Share on:

Install and upgrade of Docker Engine is simple and straightforward process.

In this post I will cover all important information in one place.

Docker install requirements

Minimum requirements

  • 8GB RAM per manager node
  • 4GB RAM per worker node
  • 3GB of free disk space

Recommended production requirements

  • 16GB RAM per manager node
  • 4 vCPUs per manager node
  • 25-100GB of free disk space on each node

Also you must have one of the following OS:

  • CentOS 7.1+ 64 bit version
  • Ubuntu 16.04/18.04/19.10 64 bit versions

Preferable storage driver on newer OS is overlay2.
Docker engine will set it by default.

If you want to get to know what is storage driver, what storage drivers are advised on certain OS and how to change it or looking for detailed info about setup of devicemapper, look at:

Docker storage driver - guide
Docker devicemapper - setup


Important

If you plan to use Docker Enterprise with multiple nodes or Swarm - remember to set up time synchro between nodes - use NTP for that.


Docker install CentOS

  • Ensure that centos-extras repo is enabled
  • Install yum-utils:
yum install -y yum-utils
  • Add repo
yum-config-manager \
  --add-repo \
  https://download.docker.com/linux/centos/docker-ce.repo
  • Install docker engine(Valid GPG Key: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35)
yum install docker-ce docker-ce-cli containerd.io

CentOS 8 at day of writing this post has problem with dependiences for containerd.io - you can solve this by installing manually correct version of containerd.io before running docker-ce instalation command. Example

yum install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
  • Start and enable autostart of daemon:
systemctl start docker
systemctl enable docker

Optionally you can list available versions of docker and install preferable one:

yum list docker-ce --showduplicates | sort -r
 yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

For installing Docker Enterprise Edition you have to set up repo on your OS after getting from Docker Hub Account Docker EE Repo Adress.


Docker install Ubuntu

  • Update system and install important packages
apt-get update

apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   gnupg-agent \
   software-properties-common
  • Add GPG Key(fingerprint: 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • Add repo
add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
  • Install docker engine
apt-get update

apt-get install docker-ce docker-ce-cli containerd.io

Optionally check available versions:

apt-cache madison docker-ce

And install specific one:

apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

Docker upgrade

Live restore

If you want that running containers won’t stop with docker daemon you can enable live restore feature. After enabling it you can perform upgrade of docker engine without stopping running containers.

In /etc/docker/daemon.json set:

{
  "live-restore": true
}

Upgrade on CentOS or Ubuntu - if we install docker engine from repo - can be performed with simple yum upgrade or apt-get upgrade commands.