"Learn now and forget now" docker foundation - 10. Docker installation

Posted by faraco on Thu, 10 Mar 2022 05:44:34 +0100

Python wechat ordering applet course video

https://edu.csdn.net/course/detail/36074

Python actual combat quantitative transaction financial management system

https://edu.csdn.net/course/detail/35475
Catalogue* 1. Premise

Three installation methods officially recommended by Docker in CentOS environment

  • Install using yum
  • Script installation method
  • Local rpm installation mode

1. Premise

  • Docker requires the kernel version of CentOS system to be higher than 3.10.
    Check your current kernel shell version with the command uname -r
[root@localhost ~ ] # uname -r
3.10.0-957.el7.x86\_64
  • Docker is currently divided into two versions:
    Docker CE (community free version)
    Docker EE (enterprise version, emphasizing security, but paying for use)
    Note: the version we installed is the community version.
  • You can also view the detailed installation method in the official Docker document:
    https://docs.docker.com/install/linux/docker-ce/centos/

2. Install Docker using yum or up2date

Install the Docker image using yum.

Before installing Docker engine community (Docker community) on the new host for the first time, you need to set up the Docker warehouse. After that, Docker can be installed and updated from the warehouse.

(1) Update yum package

In the newly installed CentOS 7, be sure to update the yum package first.

shell

$ sudo yum update

(2) Remove old Docker version

If you have installed an old version before, be sure to execute the following commands before installation.

shell

$ sudo yum remove docker \
 docker-client \
 docker-client-latest \
 docker-common \
 docker-latest \
 docker-latest-logrotate \
 docker-logrotate \
 docker-selinux \
 docker-engine-selinux \
 docker-engine

If the following prompt appears, it proves that the previous old version has not been installed.

shell

Plug in loaded: fastestmirror
 parameter docker No match
 parameter docker-client No match
 parameter docker-client-latest No match
 parameter docker-common No match
 parameter docker-latest No match
 parameter docker-latest-logrotate No match
 parameter docker-logrotate No match
 parameter docker-selinux No match
 parameter docker-engine-selinux No match
 parameter docker-engine No match
 Do not delete any packages

(3) Install required packages

  • Install Yum utils to provide the yum config manager function.
  • The device mapper persistent data and lvm2 installed at the same time are used for the device mapper storage device mapper, which are two necessary software packages. (these two packages are not required to be installed in the latest official documents)

shell

$ sudo yum install -y yum-utils \
 device-mapper-persistent-data \
 lvm2

(4) Set stable source warehouse

Configure a stable warehouse (or image warehouse) for yum to download Docker.

Official Docker image source address (not recommended)

shell

$ sudo yum-config-manager \
 --add-repo \
 https://download.docker.com/linux/centos/docker-ce.repo

Frequent download failures due to network reasons:
report errors:

shell

1[Errno 14] curl#35 - TCP connection reset by peer
2[Errno 12] curl#35 - Timeout

Alibaba's Docker image source address (recommended)

shell

$ sudo yum-config-manager \
 --add-repo \
 http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

be careful

The warehouse configuration information will be saved to / etc / yum repos. d/docker-ce. In the repo file.
There is no docker CE before the above command is executed Of the repo file. After the above command is executed, the generated docker CE Repo file.

(5) Update yum package index

shell

$ sudo yum makecache fast

This command caches a copy of the software package information locally in advance to improve the speed of searching and installing software.
This command is usually used to generate the cache after updating the yum source or reconfiguring the yum source. (it is recommended to execute this command once)

(6) Start installing docker CE

1) Install the latest version of docker CE

shell

Direct execution: $ sudo yum -y install docker-ce

2) Install the specified version of docker CE

  • Lists the available versions of Docker in the database. shell
Execution: $ yum list docker-ce --showduplicates | sort -r

docker-ce.x86\_64  3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86\_64  3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86\_64  18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86\_64  18.06.0.ce-3.el7                    docker-ce-stable
  • Select the specified version to install. shell
Execution:
$ sudo yum install docker-ce-+Version number

For example:
$ sudo yum install docker-ce-18.03.1.ce

be careful:

Docker CE, docker CE CLI and containerd are required to install docker in the official document IO three software. Let's just install docker CE directly. The other two software will automatically match the version for installation.

shell

$ sudo yum install docker-ce docker-ce-cli containerd.io

$ sudo yum install docker-ce- docker-ce-cli- containerd.io
 For example: $ sudo yum install docker-ce-18.03.1.ce

(7) View Docker version information

shell

$ sudo docker version
Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:33:55 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

# Start Docker and execute the docker version command to display more information
Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:33:55 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:32:17 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

(8) Start Docker

shell

$ sudo systemctl start docker

(9) View Docker status

shell

$ sudo systemctl status docker

(10) Join startup

bash

$ sudo systemctl enable docker

(11) Verify that Docker is installed correctly

Verify that docker engine community is installed correctly by running the Hello world image.

shell

$ sudo docker run hello-world

# The following display appears to prove that the image is running successfully

Unable to find image 'hello-world:latest' locally(Local not found hello-world Mirror image)
latest: Pulling((pull) from library/hello-world(To remote pull library/hello-world Mirror image)
1b930d010525: Pull complete((pull completed)
Digest: sha256:d1668a9a1f5b42ed3f46b70b9cb7c88fd8bdc8a2d73509bb0041cf436018fbf5
Status: Downloaded newer image for hello-world:latest
(The above three lines are the signature information of the pull image)

Hello from Docker!(Image is running)
This message shows that your installation appears to be working correctly.
(This message indicates that your installation appears to be working properly. To generate this message, Docker The following steps have been taken:)
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/

(12) View local Docker image

shell

$ sudo docker images
REPOSITORY    TAG       IMAGE ID       CREATED      SIZE
hello-world   latest    d1165f221234   8 days ago   13.3kB

(13) Stop Docker

shell

$ sudo systemctl stop docker

So far, Docker installation is completed.

  • About bloggers: comments and private messages will be replied at the first time. perhaps Direct private letter I.
  • Copyright notice: all articles on this blog are in English unless otherwise stated BY-NC-SA License agreement. Reprint please indicate the source!
  • Support bloggers: if you think the article is helpful to you, you can click * * [recommend] (javascript:void(0) in the lower right corner of the article) 😉]** once.

Topics: Operation & Maintenance Android Docker Container computer