--Easy to install Docker on Linux (CentOS).
--Understand the precautions when installing with curl | sh
.
--CentOS 7 or 8 --Docker is not installed.
Confirmed to work with AWS Lightsail on CentOS version 7.9.2009.
yum
, curl
, and systemctl
need to be read as appropriate.$ yum list installed | grep docker
If nothing is displayed, Docker is not installed and you can proceed.
$ sudo su -
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.
https://download.docker.com/linux/centos/docker-ce.repo
.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.
$ 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
# 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.
# 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
# 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/
Official site Install Docker Engine on CentOS | Docker Documentation
Recommended Posts