Centos' docker deployment and installation ultra-detailed tutorial (zero-based available)

Centos7 installation and deployment docker

Installation Environment

System: centos7 Memory: 4G

Network type: NAT mode Hard disk size: 80G

Mini-install language: English

IP:192.168.180.134

Basic environment configuration

  1. Set IP to obtain dynamically

vi /etc/sysconfig/network-scripts/ifcfg-ens33

Change BOOTPROTO="dhcp" to "static", and add IP, gateway, subnet mask, DNS information

image-20230307125445608

Restart the network and check the network information. If no error is reported, the file configuration is successful.

image-20230307125601817

At this time, the network can also be pinged normally.

image-20230307125700336

Disable firewall and close selinux

systemctl disable firewalld

systemctl stop firewalld

setenforce 0 (Temporarily closed, it will still be automatically opened after the system restarts)

permanently closed

vi /etc/selinux/config

Change SELINUX=enforcing to SELINUX=disabled then save and exit

At this point, the basic environment for installing docker has been fully configured. If you are not proficient and afraid of making mistakes in the next steps, you can take snapshots here. If you make mistakes in the next steps, just restore the snapshots

start installation

1. Uninstall the docker version that comes with the system

yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

Update the yum package (this process needs to wait for a while)

yum update

Install the dependencies required by docker

yum install -y yum-utils device-mapper-persistent-data lvm2

Configure yum source

yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

View all docker versions in the warehouse

yum list docker-ce --showduplicates | sort -r

image-20230307174224702

Install the latest version of docker, if no version number is specified, it will be installed by default

yum install -y docker-ce

(If you want to specify the version number to install, you can enter the command: yum install docker-ce-18.09* -y, and the specified version is docker-ce-18.09 at this time)

image-20230307175156745

Set docker to start automatically at boot

systemctl restart docker

systemctl enable docker

image-20230307175813294

Verify that docker is installed successfully

docker -version

image-20230307175842971

At this point, the docker installation has been completed, and some simple configurations need to be done below

Configure the daemon process of docker daemon

cd /etc/docker/

vim /etc/docker/daemon.json

Add the following configuration information:

{

“exec-opts”:[“native.cgroupdriver=systemd”]

}

image-20230307180824747

then save and exit

Configure the docker server

vi /usr/lib/systemd/system/docker.service

Add the following information:

ExecStartPost=/usr/sbin/iptables -P FORWARD ACCEPT

image-20230307181220184

then save and exit

Reload the daemon daemon

systemctl daemon-reload

View docker running status

systemctl status docker

image-20230307181840877

At this point, the display is running

Guess you like

Origin blog.csdn.net/huz1Vn/article/details/129389752