Instalar Docker en CentOS 8

En anteriores entradas os he explicado como instalar Docker tanto en Windows 10 como en Windows Server 2019. En esta ocasión, y para finalizar las entradas dedicadas a la instalación de Docker, vamos a realizar la instalación en CentOS 8.

Requisitos

  • Sudo o privilegios de root
  • Conexión a Internet.

Habilitar el repositorio Docker CE

En primer lugar tendremos que habilitar el repositorio Docker CE ya que será desde donde realizaremos la instalación.

[sergio.portillo@localhost ~]$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Instalar Docker CE

Vamos a ver cual es la versión disponible para instalar, para ello ejecutaremos el siguiente comando:

[sergio.portillo@localhost ~]$ sudo dnf list docker-ce
Paquetes disponibles
docker-ce.x86_64      3:19.03.12-3.el7      docker-ce-stable

En el momento de la realización de este tutorial la última versión disponible es la 19.03.12 por lo que vamos a proceder a su instalación.

[sergio.portillo@localhost ~]$ sudo dnf install docker-ce --nobest -y

Finalizada la instalación vamos a iniciar el servicio de Docker y hacer que se inicie junto con el sistema de forma automática.

[sergio.portillo@localhost ~]$ sudo systemctl start docker
[sergio.portillo@localhost ~]$ sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

Comprobamos que el servicio se ha iniciado correctamente:

[sergio.portillo@localhost ~]$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-09-03 17:34:52 CEST; 56s ago
     Docs: https://docs.docker.com
 Main PID: 7475 (dockerd)
    Tasks: 18
   Memory: 51.6M
   CGroup: /system.slice/docker.service
           ├─7475 /usr/bin/dockerd -H fd://
           └─7485 containerd --config /var/run/docker/containerd/containerd.toml --log-level info

sep 03 17:34:51 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:51.849116118+02:00" level=info msg="Graph migration to content-addressability took 0.00 sec>
sep 03 17:34:51 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:51.849464335+02:00" level=warning msg="Your kernel does not support cgroup blkio weight"
sep 03 17:34:51 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:51.849481970+02:00" level=warning msg="Your kernel does not support cgroup blkio weight_dev>
sep 03 17:34:51 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:51.849806700+02:00" level=info msg="Loading containers: start."
sep 03 17:34:52 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:52.150872824+02:00" level=info msg="Default bridge (docker0) is assigned with an IP address>
sep 03 17:34:52 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:52.382771572+02:00" level=info msg="Loading containers: done."
sep 03 17:34:52 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:52.405447267+02:00" level=info msg="Docker daemon" commit=4c52b90 graphdriver(s)=overlay2 v>
sep 03 17:34:52 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:52.405718781+02:00" level=info msg="Daemon has completed initialization"
sep 03 17:34:52 localhost.localdomain dockerd[7475]: time="2020-09-03T17:34:52.422390944+02:00" level=info msg="API listen on /var/run/docker.sock"
sep 03 17:34:52 localhost.localdomain systemd[1]: Started Docker Application Container Engine.

Comprobamos que la versión de Docker instalada es correcta.

[sergio.portillo@localhost ~]$ docker --version
Docker version 19.03.12, build 48a66213fe

Verificar la instalación de Docker

Por último vamos a comprobar que nuestro Docker funciona correctamente.

[sergio.portillo@localhost ~]$ sudo docker run hello-world
[sudo] password for sergio.portillo:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Y como podemos apreciar Docker ha sido instalado correctamente.

Espero os haya sido de utilidad.

Entradas relacionadas

Deja un comentario

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.