[LINUX] Docker Easy Installation Procedure (CentOS)

Contents of this article

--Easy to install Docker on Linux (CentOS). --Understand the precautions when installing with curl | sh.

Prerequisites

--CentOS 7 or 8 --Docker is not installed.

Confirmed to work with AWS Lightsail on CentOS version 7.9.2009.

Installation procedure

1. Confirmation of non-installation

$ yum list installed | grep docker

If nothing is displayed, Docker is not installed and you can proceed.

2. Switch to administrator (root)

$ sudo su -

3. Installation

Get the installation script with curl from the official website and execute it with sh.

# curl -fsSL https://get.docker.com | sh

The script automatically determines the type of Linux and executes the required command. The main contents in the case of CentOS are as follows.

  1. Install "yum-utils". (Necessary for executing 2.)
  2. In "yum-config-manager", add the Docker acquisition repository https://download.docker.com/linux/centos/docker-ce.repo.
  3. Install "docker-ce" and dependent packages.

You can also check the contents of the script from your browser. https://get.docker.com

There are some caveats with this installation method. Of course, if the provided script is malicious, it is technically possible to return the correct script when confirmed from the browser, and return an invalid script when requested from a command such as curl. Like curl -fsSL https://get.docker.com, you can check the contents without executing the script except for | sh, so check if you are worried.

In addition, a part may be missing when retrieving the script, and an unintended command may be executed. get.docker.com defines the installation process as a function "do_install", and measures are taken to execute it on the last line.

4. Check the installed packages

$ yum list installed | grep docker
containerd.io.x86_64                1.4.3-3.1.el7              @docker-ce-stable
docker-ce.x86_64                    3:20.10.2-3.el7            @docker-ce-stable
docker-ce-cli.x86_64                1:20.10.2-3.el7            @docker-ce-stable
docker-ce-rootless-extras.x86_64    20.10.2-3.el7              @docker-ce-stable

5. Autostart setting at startup / OS startup

# systemctl start docker && systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

6. Version check

# docker version
Client: Docker Engine - Community
 Version:           20.10.2
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        2291f61
 Built:             Mon Dec 28 16:17:48 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8891c58
  Built:            Mon Dec 28 16:16:13 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

7. Operation check (hello-world)

# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d
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/

reference

Official site Install Docker Engine on CentOS | Docker Documentation

Recommended Posts

Docker Easy Installation Procedure (CentOS)
Docker installation
Teamviewer for Linux installation procedure (CentOS)
centOS 7 installation error
Installation of CentOS 8
Pylearn 2 installation procedure
PHP installation (CentOS 8)
PostgreSQL 10.0 installation procedure
blockdiag installation procedure
CentOS download procedure
RDKit easy installation
CentOS 7 + ffmpeg installation
From easy git installation to docker startup python
AWS CLI installation procedure
django-debug-toolbar installation procedure memo
ubuntu20.04 + Geth installation procedure
Python 2.7 installation (yum) (CentOS 6.8)
Anaconda3 environment installation procedure
Scrapy environment installation procedure
Installation on CentOS8 VirtualBox
Python 3.5 installation (yum) (CentOS 6.8)
python (pyenv + pyenv-virtualenv) + CentOS7 installation
Offline installation procedure for openpyxl
Python CMS Mezzanine installation procedure
Python 3.6 installation procedure [for Windows]
Apache installation fails on CentOS 8.2
ubuntu 20.04 + VirtalBox installation procedure summary
Easy sample data creation procedure
NTP (Chrony) installation method (CentOS8)
raspberry pi 4 centos7 install on docker
Easy Slackbot with Docker and Errbot
Easy installation of OpenCV on RaspberryPi 3+
OpenCV installation procedure on Raspberry Pi
docker / docker-compose versioned installation (up | down)
Installation and easy usage of pytest
PySpark 1.5.2 + Elasticsearch 2.1.0 Installation procedure and execution