CentOs 7 Installation docker Record

Keywords: Python Docker yum sudo Linux

Record the next direct C, V use

Pre-examination

[root@web-95-61 /]# cat /etc/redhat-release                                                                                              
CentOS Linux release 7.6.1810 (Core)                                                                                                     
[root@web-95-61 /]# uname -a                                                                                                             
Linux web-95-61 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux                                 
[root@web-95-61 /]#   

Configuration of domestic yum sources

Reference resources:
https://blog.csdn.net/inslow/...
https://yeasy.gitbooks.io/doc...

[admin@web-95-61 ~]$ su                                                                                                                  
Password:                 
[root@web-95-61 /]# cd /etc/yum.repos.d/                                                                                                 
[root@web-95-61 yum.repos.d]# ls                                                                                                         
baofoo-centos-7.repo                                                                                                                     
[root@web-95-61 yum.repos.d]#  wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@web-95-61 yum.repos.d]# yum makecache
[root@web-95-61 yum.repos.d]# yum -y update

Install docker

Reference resources:
https://qizhanming.com/blog/2...
https://yeasy.gitbooks.io/doc...

Uninstall the old version

Old versions of Docker are called docker or docker-engine. If you install old versions of Docker, you need to uninstall it.

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

Older versions of the content can be retained under / var/lib/docker, with images, containers, volumes, and networks in the directory.

Docker CE package, currently called docker-ce

Installation preparation

To facilitate the addition of software sources and support the device mapper storage type, install the following packages

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

Add yum software source

$ sudo yum-config-manager \
    --add-repo \
    https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo


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

(Optional) If you need to test the version of DockerCE, use the following commands:

$ sudo yum-config-manager --enable docker-ce-test

If you need to build a daily version of DockerCE, use the following commands:

$ sudo yum-config-manager --enable docker-ce-nightly

Installing Docker CE

Update the cache of the yum software source and install Docker.

$ sudo yum makecache fast
$ sudo yum update
$ sudo yum install docker-ce

So far, Docker has been installed, Docker service is not started, the docker group in the operating system is created, but no users are in this group.
Be careful:
The default docker group has no users (that is, sudo is required to use the docker command).
You can add users to the docker group (this user can use the docker command directly).
(optional) Add docker user group commands

$ sudo usermod -aG docker USER_NAME

After the user updates the group information, the re-login system will take effect.

Start Docker

If you want to add it to boot start

$ sudo systemctl enable docker

Start docker service

$ sudo systemctl start docker

Verify installation

$ sudo docker run hello-world

Use rancker management to become a host

Click Add Host:

copy

New machines:

General plan:

Optimize: Linux permanently shuts down swap

What is swap:
https://www.cnblogs.com/kerry...
In order to improve the efficiency and speed of reading and writing, the Linux kernel caches files in memory, which is called Cache Memory. Cache Memory will not be released automatically even after your program runs. This will lead you to read and write files frequently in Linux systems, and you will find less physical memory available. When the physical memory of the system is insufficient, it is necessary to release a part of the physical memory for the current running program to use. The freed space may come from programs that have not operated for a long time. The freed space is temporarily saved in Swap space, and then restored from Swap partition to memory when those programs are running. In this way, the system always swaps when physical memory is insufficient.

It's better to close swap with docker. Memory overruns and poor performance.

Posted by dhiren22 on Sun, 25 Aug 2019 21:17:51 -0700