Install Docker environment in Linux environment (no pitfalls)

Install Docker environment in Linux environment (no pitfalls)

Installation Prerequisites

Docker requires the kernel version of the CentOS system to be higher than 3.10. First verify whether your server supports Docker!

Use the uname -r command to view the current kernel version

[root@iZbp18425116ezmjdmbdgeZ ~]# uname -r
4.18.0-193.14.2.el8_2.x86_64

You can see that my server is 4.18.0, which supports Docker.

Step 1: Check and clear system remnants and install Docker dependencies

1. Remove the residue

[root@iZbp18425116ezmjdmbdgeZ ~]# 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

Execution Results

No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-selinux
No match for argument: docker-engine-selinux
No match for argument: docker-engine
No packages need to be removed.
Dependency resolution.
No treatment is required.
complete!

I'm renting a new server, so there are no dependencies. (In order to ensure the smooth installation of docker, it was still executed)

Install and download tools that Docker depends on

[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2

result

Upgraded:
  device-mapper-8:1.02.177-10.el8.x86_64 device-mapper-event-8:1.02.177-10.el8.x86_64                      
  device-mapper-event-libs-8:1.02.177-10.el8.x86_64 device-mapper-libs-8:1.02.177-10.el8.x86_64                       
  device-mapper-persistent-data-0.9.0-4.el8.x86_64 dnf-4.7.0-4.el8.noarch                                            
  dnf-data-4.7.0-4.el8.noarch dnf-plugins-core-4.0.21-3.el8.noarch                              
  ima-evm-utils-1.3.2-12.el8.x86_64 libdnf-0.63.0-3.el8.x86_64                                        
  librepo-1.14.0-2.el8.x86_64 libsolv-0.7.19-1.el8.x86_64                                       
  lvm2-8:2.03.12-10.el8.x86_64 lvm2-libs-8:2.03.12-10.el8.x86_64                                 
  python3-dnf-4.7.0-4.el8.noarch python3-dnf-plugins-core-4.0.21-3.el8.noarch                      
  python3-hawkey-0.63.0-3.el8.x86_64 python3-libdnf-0.63.0-3.el8.x86_64                                
  python3-librepo-1.14.0-2.el8.x86_64 python3-rpm-4.14.3-19.el8.x86_64                                  
  rpm-4.14.3-19.el8.x86_64 rpm-build-libs-4.14.3-19.el8.x86_64                               
  rpm-libs-4.14.3-19.el8.x86_64 rpm-plugin-selinux-4.14.3-19.el8.x86_64                           
  rpm-plugin-systemd-inhibit-4.14.3-19.el8.x86_64 yum-4.7.0-4.el8.noarch                                            

Installed:
  libmodulemd-2.13.0-1.el8.x86_64 tpm2-tss-2.3.2-4.el8.x86_64 yum-utils-4.0.21-3.el8.noarch                

complete!

The content here is quite long, I only captured the ending part

Add Alibaba Cloud software source

[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

result:

Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

In the future, each software will be downloaded from Alibaba Cloud's software library first. If it is not available in the Alibaba Cloud warehouse, it will be downloaded from docker.hub. (Same as Maven repository)

Update the yum cache (to ensure that required services can be updated and downloaded: such as docker)

[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum makecache 

result:

[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum makecache
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with ID "failovermethod" does not exist CentOS-8 - AppStream 441 kB/s | 4.3 kB 00:00    
CentOS-8 - Base 437 kB/s | 3.9 kB 00:00    
CentOS-8 - Extras 194 kB/s | 1.5 kB 00:00    
Extra Packages for Enterprise Linux 8 - x86_64 602 kB/s | 4.7 kB 00:00    
Docker CE Stable - x86_64 30 kB/s | 19 kB 00:00    
The metadata cache is established.

Step 2: After the Docker dependency environment is set up, install and start Docker

1. Install Docker (CE-Community Edition)

[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum -y install docker-ce

Since Docker needs to be downloaded and installed, some machines may be a bit slow, so please be patient!

result:

Installed:
  docker-ce.x86_64 3:18.09.0-3.el7
 
Dependency Installed:
  audit-libs-python.x86_64 0:2.8.1-3.el7_5.1 checkpolicy.x86_64 0:2.5-6.el7 container-selinux.noarch 2:2.68-1.el7
  containerd.io.x86_64 0:1.2.0-3.el7 docker-ce-cli.x86_64 1:18.09.0-3.el7 libcgroup.x86_64 0:0.41-15.el7
  libseccomp.x86_64 0:2.3.1-3.el7 libsemanage-python.x86_64 0:2.5-11.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3
  policycoreutils-python.x86_64 0:2.5-22.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-2.el7
 
Dependency Updated:
  audit.x86_64 0:2.8.1-3.el7_5.1 audit-libs.x86_64 0:2.8.1-3.el7_5.1 libselinux.x86_64 0:2.5-12.el7
  libselinux-python.x86_64 0:2.5-12.el7 libselinux-utils.x86_64 0:2.5-12.el7 libsemanage.x86_64 0:2.5-11.el7
  libsepol.x86_64 0:2.5-8.1.el7 policycoreutils.x86_64 0:2.5-22.el7 selinux-policy.noarch 0:3.13.1-192.el7_5.6
  selinux-policy-targeted.noarch 0:3.13.1-192.el7_5.6
 
Complete!

See complete! Download and installation successful!

2. Start the Docker service

[root@iZbp18425116ezmjdmbdgeZ ~]# sudo systemctl start docker

Now that we have installed Docker, let's test whether Docker can be started successfully:

[root@iZbp18425116ezmjdmbdgeZ ~]# docker info

result:

Client:
 Context: default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.6.3-docker)
  scan: Docker Scan (Docker Inc., v0.9.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local

We can see that Docker has been started successfully, and the number of containers and images is 0, which means it is a brand new Docker service.

3. Set the system to start automatically (optional, set according to your own habits)

[root@iZx4xwfjh1zsdsZ /]# sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@iZx4xwfjh1zsdsZ /]#

So far, Docker has been downloaded and installed!

Check the Docker version

[root@iZbp18425116ezmjdmbdgeZ ~]# docker -v
Docker version 20.10.11, build dea9396

Remove the Docker-ce service

sudo yum remove docker-ce

Removing Docker dependencies

sudo rm -rf /var/lib/docker

This is the end of this article about installing docker environment in Linux environment (tested and no pitfalls). For more relevant content about installing docker in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker installation and deployment example on Linux
  • Steps to install MySQL using Docker under Linux
  • Golang study notes: Install Go1.15 version (win/linux/macos/docker installation)
  • Detailed explanation of how to install mongodb using docker on linux
  • The process of installing Docker in Linux system

<<:  Introduction to HTML basic controls_PowerNode Java Academy

>>:  Don’t bother with JavaScript if you can do it with CSS

Recommend

Detailed description of the function of new in JS

Table of contents 1. Example 2. Create 100 soldie...

Solution for Tomcat to place configuration files externally

question When we are developing normally, if we w...

MySQL SQL statement analysis and query optimization detailed explanation

How to obtain SQL statements with performance iss...

HTML checkbox Click the description text to select/uncheck the state

In web development, since the checkbox is small an...

KTL tool realizes the method of synchronizing data from MySQL to MySQL

Use ktl tool to synchronize data from mysql to my...

Windows 10 is too difficult to use. How to customize your Ubuntu?

Author | Editor Awen | Produced by Tu Min | CSDN ...

Detailed explanation of JavaScript program loop structure

Table of contents Select Structure Loop Structure...

Tomcat multi-instance deployment and configuration principles

1. Turn off the firewall and transfer the softwar...

JavaScript Basics: Immediate Execution Function

Table of contents Immediately execute function fo...

Detailed explanation of client configuration for vue3+electron12+dll development

Table of contents Modify the repository source st...

CSS solution for centering elements with variable width and height

1. Horizontal center Public code: html: <div c...

Tic-Tac-toe game implemented in pure CSS3

Operation effect: html <div class="tic-ta...

js+css to realize three-level navigation menu

This article example shares the specific code of ...

A brief discussion on VUE uni-app custom components

1. Parent components can pass data to child compo...