In this post we will learn how to install Docker in a Ubuntu 20.04 Docker is the de facto standard to make containerized apps.
I need a way to practice and make further laboratories, and the best way to encapsulate the environment is with Docker.
Requirements:
- Ubuntu Image
- Linux basic knowlage
- Docker basic knowlage
Hands-On:
- Uninstall any old docker version
This will preserve the content in /var/lib/docker/ of any image, volume and configuration of old docker
sudo apt-get remove docker docker-engine docker.io containerd run
2. Install docker dependencies
sudo apt update && sudo apt install -y \
apt-transport-https ca-certificates curl \
gnupg-agent software-properties-common
3. Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | \
sudo apt-key add -
4. Set up the stable repository of Docker in our machine.
This is for x86_64 / amd64 if you need other version you can get the command here
sudo add-apt-repository "deb [arch=amd64] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable"
5. Update and install docker
sudo apt-get update && sudo apt install -y docker-ce \
docker-ce-cli containerd.io
If you try to use the same command in the actual user (without sudo) you will get an error like this
docker version
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46
Built: Wed Sep 16 17:03:40 2020
OS/Arch: linux/amd64
Experimental: false
Got permission denied while trying to connect to the Docker daemon socket at
unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version:
dial unix /var/run/docker.sock: connect: permission denied Client: Docker Engine - Community
This is because you need to add the current user to the docker group
sudo usermod -aG docker $USER
6. Apply the changes to the group, you can restart, or you can use the newgrp command
newgrp docker
7. Test the installation with docker version
docker version
Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46
Built: Wed Sep 16 17:03:40 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46
Built: Wed Sep 16 17:02:11 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Well done, Docker installed and working.
References: