Installing Docker CE
This is how to install the Community Edition of Docker.
Install Prerequisites
Some packages needed to install this apt-repository.
Add Key and Sourcelist
Official solution
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" >> /etc/apt/sources.list.d/docker.list
Generic solution
Probably a better than the official one using a sources-file.
cat <<EOD | sudo tee /etc/apt/sources.list.d/docker-ce.sources >/dev/null
Types: deb
URIs: https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')
Suites: $(lsb_release -cs)
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By:
$(wget -qO- "https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg" | sed 's/^/ /')
EOD
For older distributions not supporting .sources files.
curl -fsSL "https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg" | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') stable" >>/etc/apt/sources.list.d/docker.list
Install the Package
Sanity Check
Check that the package is coming from the docker repository.
Add Group to User
To allow a non-root user to use docker add the docker group to the user.
Move Docker Storage to Another Device
By default, the Docker storage location is /var/lib/docker.
To check the where the location is, execute this command.
Change it by following the next steps.
1) Stop the Services
2) Move the Existing Data
3) Configuration Changes
Change: Storage Location Image Layers
Modify the file /etc/docker/daemon.json by adding the next part to the possible existing configuration.
Log to journald for all Daemon Containers
Modify the file /etc/docker/daemon.json by adding the next part to the possible existing configuration.
Add TCP port for Daemon
Modify the file /etc/docker/daemon.json by adding the next part to the possible existing configuration.
Remove conflicting json-file option from service file /usr/lib/systemd/system/docker.service by
issuing command systemctl edit docker.service and insert the section and entries to be changed like this:
[Service]
# Clear the entry before assigning a complete new one. (Causes an error otherwise.)
ExecStart=
ExecStart=/usr/bin/dockerd --containerd=/run/containerd/containerd.sock
The file /etc/systemd/system/docker.service.d/override.conf is created upon closing the editor.
1) Start the Services
Start or restart the services.