Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install docker environment under Linux environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to install the docker environment under the Linux environment". In the daily operation, I believe that many people have doubts about how to install the docker environment under the Linux environment. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubts about "how to install the docker environment in the Linux environment". Next, please follow the editor to study!

Installation prerequisites

Docker requires that the kernel version of the CentOS system is higher than 3.10. First verify that your server supports Docker!

View the current kernel version through the uname-r command

[root@iZbp18425116ezmjdmbdgeZ] # uname-r4.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 the system remnants and install the Docker dependent environment

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 result

No match for argument: dockerNo match for argument: docker-clientNo match for argument: docker-client-latestNo match for argument: docker-commonNo match for argument: docker-latestNo match for argument: docker-latest-logrotateNo match for argument: docker-logrotateNo match for argument: docker-selinuxNo match for argument: docker-engine-selinuxNo match for argument: docker-engine there are no packages to remove. Dependency resolution. No need to deal with it. Over!

Mine is a newly rented server, so there are no dependencies. (in order to ensure the smooth installation of docker, it was 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. X8634 libsolv-0.7.19-1.el8.x86_64 lvm2- 8vl 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 has been 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 over!

The content here is rather long. I only intercepted the end part.

Add the software source of Aliyun

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

Results:

Loaded plugins: fastestmirroradding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repograbbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to / etc/yum.repos.d/docker-ce.reporepo saved to / etc/yum.repos.d/docker-ce.repo

In the future, each software will be downloaded from Aliyun's software library, and if it is not available in Aliyun's warehouse, it will be downloaded to docker.hub. (same as maven warehouse)

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

[root@iZbp18425116ezmjdmbdgeZ ~] # sudo yum makecache

Results:

[root@iZbp18425116ezmjdmbdgeZ ~] # sudo yum makecacheInvalid configuration value: failovermethod=priority in / etc/yum.repos.d/CentOS-epel.repo Configuration: OptionBinding with "failovermethod" ID 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 million 64 602 kB/s | 4.7 kB 00:00 Docker CE Stable-x86 regions 64 30 kB/s | 19 kB 00:00 metadata cache has been 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

Due to the need to download and install docker, some machines will be a little slow, please wait patiently!

Results:

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

See complete! Download and install successfully!

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 smoothly:

[root@iZbp18425116ezmjdmbdgeZ ~] # docker info

Results:

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, so it is a brand new docker service.

3. Set self-boot (optional, set according to your own habits)

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

At this point, Docker has been downloaded and installed!

View docker version

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

Remove Docker-ce service

Sudo yum remove docker-ce

Delete Docker dependencies

Sudo rm-rf / var/lib/docker at this point, the study on "how to install the docker environment in the Linux environment" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report