Installation and use of Docker under CentOS

Keywords: Docker yum CentOS sudo

1, Preparation

The system requires CentOS 7.X and above, with a kernel of at least 3.10 and 64 bit

1.1. Use uname -r to check the kernel version

[root@localhost ~]# uname -r

1.2. Set up Alibaba CentOS warehouse to update plug-ins / software packages more smoothly

Step 1: execute the following command to download CentOS-7 image warehouse to CentOS-Base.repo The name is saved in / etc/yum.repos.d / directory.

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo

Step 2: execute the following command to cache the package information on the server locally to improve the speed of searching and installing software.

[root@localhost ~]# yum makecache

Step 3: execute the following command to update the software package

[root@localhost ~]# yum update

1.3 add yum warehouse

[root@localhost ~]#sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
name=Docker Repository

2. Installation

2.1. Install docker

[root@localhost ~]# sudo yum install docker-engine

2.2. Start docker service

[root@localhost ~]# sudo systemctl enable docker.service

2.3. Start docker guard

[root@localhost ~]# sudo systemctl start docker

3. Verification

[root@localhost ~]# sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete 
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
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.
 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:

For more examples and ideas, visit:

The whole process is as follows:

The Docker client connects to the Docker daemons;
The Docker daemons pull an image named "Hello world" from the Docker Hub (image);
The Docker daemons create a new container from the image. The container performs the output action, and the output content is what you see above;
The Docker daemons stream the output to the Docker client and send your terminal display.

4. View docker image

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              f2a91732366c        3 weeks ago         1.85kB

Posted by eurozaf on Sun, 31 May 2020 01:59:17 -0700