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 and uninstall docker Application Container engine under Centos7

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to install and uninstall docker application container engine under Centos7". In daily operation, I believe many people have doubts about how to install and uninstall docker application container engine under Centos7. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to install and uninstall docker application container engine under Centos7". Next, please follow the editor to study!

Docker is an open source application container engine based on the go language and open source according to the apache2.0 protocol.

Docker allows developers to package their applications and dependencies into a lightweight, portable container and publish them to any popular linux machine.

Containers are completely sandboxed and do not have any interfaces to each other (similar to iphone's app). More importantly, the container performance overhead is extremely low.

Application scenarios of docker

Automated packaging and distribution of web applications.

Automated testing and continuous integration and release.

Deploy and adjust databases or other background applications in a service-oriented environment.

Build your own paas environment by compiling or extending existing openshift or cloud foundry platforms from scratch.

Advantages of docker

1. Simplify the procedure:

Docker allows developers to package their applications and dependency packages into a portable container and publish them to any popular linux machine for virtualization. Docker has changed the way it is virtualized, allowing developers to manage their work directly in docker. Convenience and rapidity is already the biggest advantage of docker. In the past, tasks that took days or even weeks could be completed in seconds under the docker container.

2. Avoid choice phobia:

If you have choice phobia, you are a senior patient. Docker helps you pack up your entanglements! For example, docker image; docker image contains the running environment and configuration, so docker can simplify the deployment of multiple application instances. For example, web applications, background applications, database applications, big data applications such as hadoop cluster, message queue and so on can be packaged into a mirror deployment.

3. Save money:

On the one hand, with the advent of the era of cloud computing, developers do not have to configure high hardware in order to pursue results, and docker has changed the mindset of high performance and high price. The combination of docker and cloud makes the cloud space more fully utilized. It not only solves the problem of hardware management, but also changes the way of virtualization.

Installation of 1.docker:

Docker supports the following centos versions:

Centos 7 (64-bit)

Centos 6.5 (64-bit) or later

1.2 prerequisites

Currently, only kernels in centos distributions support docker.

Docker runs on centos 7 and requires a 64-bit system with a kernel version of 3.10 or above.

Docker runs on centos-6.5 or later centos and requires the system to be 64-bit and the system kernel version 2.6.32-431 or later.

My operating system version:

Centos7 official English installation docker ce instructions:

Centos7 Chinese installation docker ce instructions

The docker package and dependency package are already included in the default centos-extras software source. You can update the yum source and choose the yum install method to install, or you can download the rpm installation package.

Official download address: https://download.docker.com/linux/centos/7/x86_64/stable/packages/

You can install docker ce in different ways according to your needs:

Most users set up and install docker's repository for installation and upgrade tasks. This is the recommended method.

Some users download the rpm package, install it manually, and manage the upgrade completely. This is useful for situations such as installing docker on gap systems that do not have access to the Internet.

1.3 use the wget command to download the rpm package

Create a downloads folder and download it using the wget command

[root@sungeek downloads] # wget https://download.docker.com/linux/centos/7/x86_64/stable/packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm[root@sungeek downloads] # yum install docker-ce-18.03.0.ce-1.el7.centos.x86_64.rpm

1.4 install using repositories (recommended method-but domestic pull of foreign repositories is slow)

Before you install docker ce on a new host for the first time, you need to set up the docker repository. You can then install and update docker from the repository.

Set up the repository

1. Install the required packages. Yum-utils provides yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by devicemapper storage drivers.

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

two。 Use the following command to set up the repository for stable. Even if you want to install a build from an edge or test repository, you always need a repository for stable.

[root@sungeek ~] # yum-config-manager\-add-repo\ https://download.docker.com/linux/centos/docker-ce.repo

3. Optional: enable edge and test repositories. These repositories are included in the files above docker.repo, but are disabled by default. You can enable them with a stable repository.

[root@sungeek] # yum-config-manager-- enable docker-ce-edge [root@sungeek ~] # yum-config-manager-- enable docker-ce-test

You can disable the edge or test repository by running the command using this flag. To re-enable it, use the flag. The following command disables the edge repository. Yum-config-manager--disable--enable

[root@sungeek] # yum-config-manager-- disable docker-ce-edge

Note: starting from docker 17. 06, the stable version is also pushed to the edge and test version library.

Install docker ce- [I can only pull the server by setting vpn, access to foreign resources is very slow and often times out]

1. Update the yum package index.

[root@sungeek ~] # yum makecache fastloaded plugins: fastestmirror Langpacksloading mirror speeds from cached hostfile* base: mirrors.cn99.com* extras: mirrors.shu.edu.cn* updates: mirrors.shu.edu.cnbase | 3.6kb 00:00:00 docker-ce-edge | 2.9kb 00:00:00 docker-ce-stable | 2.9kb 00:00:00 docker-ce-test | 2.9kb 00:00:00 extras | 3.4kb 00:00:00 updates | 3.4kb 00:00:00 docker-ce-test/x86_64 / primary_db | 47 kb 00:00:00 metadata cache created

If this is the first time you have refreshed the package index since you added the docker image repository, you will be prompted to accept the gpg key and the fingerprint of the key will be displayed. Verify that the fingerprint is correct and accept the key if it is correct. The fingerprint should match 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35.

two。 Install the latest version of docker ce, or go to the next step to install a specific version.

[root@sungeek ~] # yum install docker-ce

Warning: if you have multiple docker image repositories enabled, installing or updating without specifying a version in the yum install or yum update command will always install the highest version available, which may not meet your stability requirements.

3. In a production system, you should install a specific version of docker ce instead of always using the latest version. List the available versions. This example uses the sort-r command to sort the results by version number (from highest to lowest) and has been truncated.

Note: this yum list command displays only binary packages. If you also need to display the source package, omit .x86 _ 64 from the package name.

[root@sungeek ~] # yum list docker-ce.x86_64-- showduplicates | sort-rdocker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable

The list returned depends on which repositories are enabled and are specific to your version of centos (.el7 is indicated by the suffix in this example).

For example, install a specific version with a fully qualified package name (which is the package name (docker-ce) and a version string (column 2) up to the first hyphen, and separate the docker-ce-18.03.0.ce with a hyphen (-)

[root@sungeek ~] # yum install docker-ce- [root@sungeek ~] # yum install docker-ce-docker-ce-18.03.0.ce-1.el7.centos

Upgrade docker ce

To upgrade docker ce, first run yum makecache fast, then follow, and select the new version you want to install.

Description: domestic through the above method will show pull timeout, because foreign resources access is very slow, often timeout!

Https://download.docker.com/linux/centos/7/x86_64/test/repodata/f4f313b71260886934a949b16efa15e5032e0b16c4cd26c1e87fdbf935d039d1-primary.sqlite.bz2: [errno 12] timeout on https://download.docker.com/linux/centos/7/x86_64/test/repodata/f4f313b71260886934a949b16efa15e5032e0b16c4cd26c1e87fdbf935d039d1-primary.sqlite.bz2: (28, 'operation timed out after 30001 milliseconds with 0 out of 0 bytes received')

Trying other mirror.

1.5 start the docker process

[root@localhost downloads] # systemctl start docker [root@localhost downloads] # systemctl status docker [root@localhost downloads] # systemctl enable docker-- set the docker service to boot automatically

1.6 verify that the installation is successful

Enter docker directly to list the usage of the command

The first container for the test run: hello-world

Since there is no hello-world image locally, a hello-world image will be downloaded and run in the container.

two。 Some of the most commonly used commands

2.1 use docker images to view images

[root@localhost downloads] # docker imagesrepository tag image id created sizedocker.io/hello-world latest e38bc07ac18e 2 months ago 1.85 kb

2.2 use docker ps-a to view containers

[root@localhost downloads] # docker ps-acontainer id image command created status ports names3fa4f2de1c01 hello-world "/ hello" 4 minutes ago exited (0) 4 minutes ago elastic_lumiere

Docker ps is also the most commonly used command,-a: displays all containers, including those that are not running.

2.3 View Container console output using docker logs

Get the log of the container

Docker logs [container]

2.4 Uninstall docker

1. Query installed packages

[root@sungeek ~] # yum list installed | grep dockerdocker-client.x86_64 2 grep dockerdocker-client.x86_64 1.13.1-63.git94f4240.el7.centos @ extras docker-common.x86_64 2 race 1.13.1-63.git94f4240.el7.centos @ extras

two。 Remove installed software packages

[root@sungeek ~] # yum-y remove docker-client.x86_64 [root@sungeek ~] # yum-y remove docker-common.x86_64

3. Delete images / containers, etc.

[root@sungeek ~] # rm-rf / var/lib/docker/

4. Enter docker or docker-- version to verify whether to uninstall

[root@sungeek ~] # docker--version-bash: / usr/bin/docker: no such file or directory [root@sungeek ~] # docker-bash: / usr/bin/docker: no such file or directory

5. If you find it inappropriate to import and load it, you can delete it by using docker rm container id and docker rmi image id.

Remove all containers and images:

The copy code is as follows:

[root@sungeek] # docker kill $(docker ps-Q); docker rm $(docker ps-a-Q); docker rmi $(docker images-Q-a)

At this point, the study on "how to install and uninstall the docker application container engine under Centos7" 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