Pré-requisitos - requisitos do
sistema operacional
Para instalar o Docker Engine,
você precisa da versão de 64 bits de uma destas versões do Ubuntu:
·
Ubuntu
Hirsute 21.04
·
Ubuntu
Groovy 20.10
·
Ubuntu
Focal 20.04 (LTS)
·
Ubuntu
Bionic 18.04 (LTS)
Uma Docker referenciada ao mundo
da tecnologia é uma forma de virtualizar aplicações no conceito de “containers”,
trazendo da web ou do seu repositório uma instância totalmente pronta para uso,
incluindo todas as dependências necessárias para suas funcionalidades. Esta
tecnologia surgiu sob a ótica de um projeto de software de código aberto, há
uma comunidade open source que auxilia um grupo de voluntários no apoio para
melhoria continuada do seu sistema.
O Docker Engine é compatível
com x86_64(ou amd64) armhf, e arm64arquiteturas.
Desinstale versões antigas
Versões mais antigas do Docker
foram chamados docker, docker.ioou docker-engine. Se
estiverem instalados, desinstale-os:
sudo apt-get remove docker
docker-engine docker.io containerd runc
Tudo bem se
apt-getrelatar que nenhum desses pacotes está instalado. O conteúdo de
/var/lib/docker/, incluindo imagens, contêineres, volumes e redes, é
preservado.
Desinstale versões antigas
Você pode
instalar o Docker Engine de diferentes maneiras, dependendo de suas
necessidades. Neste artigo será apresentada uma forma via repositório:
A maioria dos usuários configura os repositórios do
Docker e instala a partir do seu repositório, para facilitar as tarefas de
instalação e atualização. Esta é a abordagem recomendada.
1.
Instale
usando o repositório
Antes de
instalar o Docker Engine pela primeira vez em uma nova máquina host, você
precisa configurar o repositório do Docker. Depois disso, você pode instalar e
atualizar o Docker a partir do repositório.
Configure o
repositório
Atualize o apt índice
do pacote e instale os pacotes para permitir o apt uso de um repositório por
HTTPS:
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
2.
Adicione
a chave GPG oficial Docker
curl -fsSL
https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o
/usr/share/keyrings/docker-archive-keyring.gpg
3.
Use o
seguinte comando para configurar o repositório estável
echo \
"deb
[arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/ubuntu \
$(lsb_release
-cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4.
Instale
o Docker Engine
Atualize
o sistema usando o apt e instale a versão mais recente do Docker Engine e
containerd.
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli
containerd.io
SAÍDA
DOS COMANDOS:
root@ssl0:~#
docker -v
-bash:
docker: command not found
root@ssl0:~#
apt-get install docker-ce
Reading
package lists... Done
Building
dependency tree
Reading
state information... Done
Package
docker-ce is not available, but is referred to by another package.
This may
mean that the package is missing, has been obsoleted, or
is only
available from another source
E:
Package 'docker-ce' has no installation candidate
root@ssl0:~#
apt-get install docker
Reading
package lists... Done
Building
dependency tree
Reading
state information... Done
docker is
already the newest version (1.5-1build1).
0
upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
root@ssl0:~#
apt-get remove docker docker-engine docker.io containerd runc
Reading
package lists... Done
Building
dependency tree
Reading
state information... Done
Package
'docker-engine' is not installed, so not removed
Package
'containerd' is not installed, so not removed
Package
'docker.io' is not installed, so not removed
Package
'runc' is not installed, so not removed
The
following packages will be REMOVED:
docker
0
upgraded, 0 newly installed, 1 to remove and 39 not upgraded.
After
this operation, 45.1 kB disk space will be freed.
Do you
want to continue? [Y/n] y
(Reading
database ... 30626 files and directories currently installed.)
Removing
docker (1.5-1build1) ...
Processing
triggers for man-db (2.8.3-2ubuntu0.1) ...
root@ssl0:~#
apt-get install \
> apt-transport-https \
> ca-certificates \
> curl \
> gnupg \
> lsb-release
Reading
package lists... Done
Building
dependency tree
Reading
state information... Done
lsb-release
is already the newest version (9.20170808ubuntu1).
ca-certificates
is already the newest version (20210119~18.04.1).
gnupg is
already the newest version (2.2.4-1ubuntu1.4).
The
following additional packages will be installed:
libcurl4
The
following NEW packages will be installed:
apt-transport-https
The
following packages will be upgraded:
curl libcurl4
2
upgraded, 1 newly installed, 0 to remove and 37 not upgraded.
Need to
get 382 kB of archives.
After
this operation, 154 kB of additional disk space will be used.
Do you
want to continue? [Y/n] y
Get:1
http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64
apt-transport-https all 1.6.14 [4348 B]
Get:2
http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64
7.58.0-2ubuntu3.14 [159 kB]
Get:3
http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.14
[219 kB]
Fetched
382 kB in 0s (1966 kB/s)
Selecting
previously unselected package apt-transport-https.
(Reading
database ... 30621 files and directories currently installed.)
Preparing
to unpack .../apt-transport-https_1.6.14_all.deb ...
Unpacking
apt-transport-https (1.6.14) ...
Preparing
to unpack .../curl_7.58.0-2ubuntu3.14_amd64.deb ...
Unpacking
curl (7.58.0-2ubuntu3.14) over (7.58.0-2ubuntu3.13) ...
Preparing
to unpack .../libcurl4_7.58.0-2ubuntu3.14_amd64.deb ...
Unpacking
libcurl4:amd64 (7.58.0-2ubuntu3.14) over (7.58.0-2ubuntu3.13) ...
Setting
up apt-transport-https (1.6.14) ...
Setting
up libcurl4:amd64 (7.58.0-2ubuntu3.14) ...
Setting
up curl (7.58.0-2ubuntu3.14) ...
Processing
triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing
triggers for libc-bin (2.27-3ubuntu1.4) ...
root@ssl0:~#
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o
/usr/share/keyrings/docker-archive-keyring.gpg
root@ssl0:~#
echo \
> "deb [arch=amd64
signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) stable" | sudo tee
/etc/apt/sources.list.d/docker.list > /dev/null
root@ssl0:~#
apt-get update
Hit:1
http://archive.canonical.com/ubuntu bionic InRelease
Hit:2
http://archive.ubuntu.com/ubuntu bionic InRelease
Get:3
http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4
https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:5
http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6
https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [19.1 kB]
Get:7
http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2160 kB]
Get:8
http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [413
kB]
Get:9
http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [56.0
kB]
Get:10
http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1743
kB]
Get:11
http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [373
kB]
Get:12
http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1814 kB]
Get:13
http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages
[389 kB]
Get:14
http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en
[52.3 kB]
Get:15
http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1132
kB]
Get:16
http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages
[20.9 kB]
Get:17
http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en
[4732 B]
Fetched
8420 kB in 3s (3283 kB/s)
Reading
package lists... Done
root@ssl0:~#
apt-get install docker-ce docker-ce-cli containerd.io
Reading
package lists... Done
Building
dependency tree
Reading
state information... Done
The
following additional packages will be installed:
apparmor docker-ce-rootless-extras docker-scan-plugin
pigz
Suggested
packages:
apparmor-profiles-extra apparmor-utils
aufs-tools cgroupfs-mount | cgroup-lite
Recommended
packages:
slirp4netns
The
following NEW packages will be installed:
apparmor containerd.io docker-ce
docker-ce-cli docker-ce-rootless-extras docker-scan-plugin pigz
0
upgraded, 7 newly installed, 0 to remove and 37 not upgraded.
Need to
get 104 MB of archives.
After
this operation, 450 MB of additional disk space will be used.
Do you
want to continue? [Y/n] y
Get:1
http://archive.ubuntu.com/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57.4
kB]
Get:2
https://download.docker.com/linux/ubuntu bionic/stable amd64 containerd.io
amd64 1.4.8-1 [24.7 MB]
Get:3
http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 apparmor amd64 2.12-4ubuntu5.1
[487 kB]
Get:4
https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce-cli
amd64 5:20.10.7~3-0~ubuntu-bionic [41.4 MB]
Get:5
https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce amd64
5:20.10.7~3-0~ubuntu-bionic [24.8 MB]
Get:6
https://download.docker.com/linux/ubuntu bionic/stable amd64
docker-ce-rootless-extras amd64 5:20.10.7~3-0~ubuntu-bionic [9061 kB]
Get:7
https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-scan-plugin
amd64 0.8.0~ubuntu-bionic [3888 kB]
Fetched
104 MB in 9s (11.9 MB/s)
Preconfiguring
packages ...
Selecting
previously unselected package pigz.
(Reading
database ... 30625 files and directories currently installed.)
Preparing
to unpack .../0-pigz_2.4-1_amd64.deb ...
Unpacking
pigz (2.4-1) ...
Selecting
previously unselected package apparmor.
Preparing
to unpack .../1-apparmor_2.12-4ubuntu5.1_amd64.deb ...
Unpacking
apparmor (2.12-4ubuntu5.1) ...
Selecting
previously unselected package containerd.io.
Preparing
to unpack .../2-containerd.io_1.4.8-1_amd64.deb ...
Unpacking
containerd.io (1.4.8-1) ...
Selecting
previously unselected package docker-ce-cli.
Preparing
to unpack .../3-docker-ce-cli_5%3a20.10.7~3-0~ubuntu-bionic_amd64.deb ...
Unpacking
docker-ce-cli (5:20.10.7~3-0~ubuntu-bionic) ...
Selecting
previously unselected package docker-ce.
Preparing
to unpack .../4-docker-ce_5%3a20.10.7~3-0~ubuntu-bionic_amd64.deb ...
Unpacking
docker-ce (5:20.10.7~3-0~ubuntu-bionic) ...
Selecting
previously unselected package docker-ce-rootless-extras.
Preparing
to unpack
.../5-docker-ce-rootless-extras_5%3a20.10.7~3-0~ubuntu-bionic_amd64.deb ...
Unpacking
docker-ce-rootless-extras (5:20.10.7~3-0~ubuntu-bionic) ...
Selecting
previously unselected package docker-scan-plugin.
Preparing
to unpack .../6-docker-scan-plugin_0.8.0~ubuntu-bionic_amd64.deb ...
Unpacking
docker-scan-plugin (0.8.0~ubuntu-bionic) ...
Setting
up containerd.io (1.4.8-1) ...
Created
symlink /etc/systemd/system/multi-user.target.wants/containerd.service →
/lib/systemd/system/containerd.service.
Setting
up docker-ce-rootless-extras (5:20.10.7~3-0~ubuntu-bionic) ...
Setting
up docker-scan-plugin (0.8.0~ubuntu-bionic) ...
Setting
up apparmor (2.12-4ubuntu5.1) ...
Created
symlink /etc/systemd/system/sysinit.target.wants/apparmor.service →
/lib/systemd/system/apparmor.service.
Setting
up docker-ce-cli (5:20.10.7~3-0~ubuntu-bionic) ...
Setting
up pigz (2.4-1) ...
Setting
up docker-ce (5:20.10.7~3-0~ubuntu-bionic) ...
Created
symlink /etc/systemd/system/multi-user.target.wants/docker.service →
/lib/systemd/system/docker.service.
Created
symlink /etc/systemd/system/sockets.target.wants/docker.socket →
/lib/systemd/system/docker.socket.
Processing
triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing
triggers for systemd (237-3ubuntu10.47) ...
root@ssl0:~#
docker -v
Docker
version 20.10.7, build f0df350
Fonte: https://docs.docker.com/engine/install/ubuntu/