This is my second day of the Gwen Challenge
1. Preparation
Personal learning habits, using the VIRTUAL machine to operate, so I modify the corresponding computer name and set the static IP address
(1) Modify the /etc/hostname file to contain the computer name
Enter the following command: vi /etc/hostname Use the X key on the keyboard to delete all contents one by one, and then use the I key on the keyboard to enter the editable state. Enter the computer name centos7-docker and run the :wq command to save the modification and exitCopy the code
(2) Modify the /etc/sysconfig/network-scripts/ifcfg-ens33 file
Enter the command: Vi /etc/sysconfig/network-scripts/ifcfg-ens33 // Go to the ens33 configuration page of the NIC. Press I on the keyboard to enter the editing mode. The modification is as follows: ----- BOOTPROTO="static" // Modify: BOOTPROTO=static 4.2 ONBOOT=yes 4.3 IPADDR="192.168.213.20" // Added: 4.4 NETMASK=" 255.XXX.xxx.xxx "// New: Configure the subnet mask 4.5 GATEWAY=" XXX.XXX.xxx. XXX" // New: Configure the subnet mask. 4.6dNS1 =" xxx.XXX.xxx.xxx "// Added: Configure DNS ----- Esc or Ctrl+ C // Exit file editing mode :wq // Save the configuration and exit ----- service network restartCopy the code
(3) Add a line to the /etc/hosts file
Run the vi /etc/hosts command to move the cursor to 127.0.0.1 localhost. Run the I command to insert the following content: 192.168.213.20 centos7-docker in the command, centos7-docker indicates the computer name. After the computer name is changed, run the :wq command to save the configuration and exitCopy the code
2. Install Docker (official documentation)
Centos installation
(1) Remove the existing Docker version. If Docker has not been installed before, you can ignore this step
$sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
Copy the code
(2) Log in to Centos as user root. Make sure the YUM package is up to date.
yum update
Copy the code
(3) Install the required package, yum-util provides yum-config-manager functionality, the other two are devicemapper driver dependent
yum install -y yum-utils device-mapper-persistent-data lvm2
Copy the code
(4) Configure the yum source
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
Copy the code
(5) You can view all docker versions in all warehouses and select a specific version to install
yum list docker-ce --showduplicates | sort -r
Copy the code
(6) Install docker, because the repo only opens stable repository by default, so here is the latest stable version 20.10.1 installed
yum install docker-ce docker-ce-cli containerd.io -y
Copy the code
Yum install
# for example, ym install docker-ce-17.12.0.ce
(7) Start and join boot startup
systemctl start docker
systemctl enable docker
Copy the code
(8) Verify whether the installation is successful (client and Service indicate that docker has been successfully installed and started)
Docker version or use docker --versionCopy the code
3. Configure the domestic mirror source
After the default installation of Docker, when the Docker pull command is used to pull the image, the image on the Docker Hub is accessed by default. In the domestic network environment, the download takes a long time, so the domestic image repository needs to be configured.
I’m using 163’s open source mirror accelerator
(1) Create or edit daemon.json
vi /etc/docker/daemon.json
Copy the code
(2) Edit contents in daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]}Copy the code
(3) Restart the Docker
// Optional operation command systemctl daemon-reload ----- systemctl restart docker.service // or systemctl restart dockerCopy the code
(4) Check whether the modification is successful
docker info
Copy the code
(5) Domestic accelerator address
1. Netease http://hub-mirror.c.163.com 2.Docker China official mirror https://registry.docker-cn.com 3. https://docker.mirrors.ustc.edu.cn 4 China university of science and technology. Ali cloud container service https://cr.console.aliyun.com/ home page, click on the "create my container mirror" to get an exclusive image of accelerating address, similar to the "https://XXXXXXXX.mirror.aliyuncs.com"Copy the code