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

Advantages of MySQL covering indexes

A common suggestion is to create indexes for WHER...

A simple way to implement all functions of shopping cart in Vue

The main functions are as follows: Add product in...

Markup Language - Phrase Elements

Click here to return to the 123WORDPRESS.COM HTML ...

Introduction to the use of http-equiv attribute in meta tag

meta is an auxiliary tag in the head area of ​​htm...

MySQL 8.0.12 installation configuration method and password change

This article records the installation and configu...

HTML table markup tutorial (5): light border color attribute BORDERCOLORLIGHT

In a table, you can define the color of the upper...

Automatic file synchronization between two Linux servers

When server B (172.17.166.11) is powered on or re...

How to connect Django 2.2 to MySQL database

1. The error information reported when running th...

CSS eight eye-catching HOVER effect sample code

1. Send effect HTML <div id="send-btn&quo...

Example code for implementing raindrop animation effect with CSS

Glass Windows What we are going to achieve today ...

Solve the problem of installing Theano on Ubuntu 19

Solution: Directly in the directory where you dow...

Summary of Linux vi command knowledge points and usage

Detailed explanation of Linux vi command The vi e...

Vue implements table paging function

This article example shares the specific code of ...