Docker in Ubuntu 20 (problems with docker-ce)

Hi all,

I’m posting this information for a double purposes:

  • To try to help future Docker`s users in Ubuntu 20
  • To try to get some explanation

I got a problem during Docker installation (in particular with docker-ce installation) into an Ubuntu 20 server. There were no more libraries nor programs installed on the server (only Ubuntu 20 clean installation).
Bellow can be found more SO details:

$> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:         20.04
Codename:     focal
$> uname -a
Linux egnos-next-tb-vm1 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I followed the official documentation (Install Docker Engine on Ubuntu | Docker Documentation) but I got this error when trying to install docker-ce. Here it is the whole error trace:

$> sudo -E apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/84.8 MB of archives.
After this operation, 371 MB of additional disk space will be used.
Selecting previously unselected package containerd.io.
(Reading database ... 108311 files and directories currently installed.)
Preparing to unpack .../containerd.io_1.4.9-1_amd64.deb ...
Unpacking containerd.io (1.4.9-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../docker-ce-cli_5%3a20.10.8~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce-cli (5:20.10.8~3-0~ubuntu-focal) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_5%3a20.10.8~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce (5:20.10.8~3-0~ubuntu-focal) ...
Setting up containerd.io (1.4.9-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-ce-cli (5:20.10.8~3-0~ubuntu-focal) ...
Setting up docker-ce (5:20.10.8~3-0~ubuntu-focal) ...
groupadd: Can't get unique GID (no more available GIDs)
dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 4
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.11) ...
Errors were encountered while processing:
 docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)

Apparently the problem is wen trying to create the docker group (groupadd: Can’t get unique GID (no more available GIDs))

I was able to solve the problem by editing the file /etc/login.defs and setting the SYS_GID_MIN and SYS_GID_MAX parameters as follow:

SYS_GID_MIN               2000
SYS_GID_MAX              9000

Previous values were 100 and 999.

Within the same network I have other severs with Ubuntu 18.04.4 LTS (4.15.0-154-generic) and I had no problems to install Ubuntu (just following the same official documentation).

Does anyone have an explanation?

Thank you very much!