Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install CentOS7 and use Docker

Shulou Source: shulou.com Published: 2022-05-31 22:56:55 10月04日 Update

This article mainly introduces CentOS7 how to install and use Docker related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have a harvest after reading this CentOS7 how to install and use Docker article, let's take a look at it.

Installation

Docker officially provides a set of installation scripts to simplify the installation process, which can be used on centos systems:

Curl-ssl https://get.docker.com/ | sh

After executing this command, the script automatically prepares everything and installs docker on the system.

However, due to the great wall, there may be some download errors when using this script in China. Some domestic cloud service providers have provided a modified version of this script to use the domestic docker software source mirror installation, so as to avoid wall interference.

Aliyun installation script

The copy code is as follows:

Curl-ssl | sh

Mirror image

Select a domestic mirror image

Official accelerator in China

The copy code is as follows:

Sudo echo "docker_opts=\"-registry-mirror= https://registry.docker-cn.com\"" > > / etc/default/docker

Official accelerators are recommended.

NetEase 163

The copy code is as follows:

Sudo echo "docker_opts=\"-registry-mirror= http://hub-mirror.c.163.com\"" > > / etc/default/docker

At present, the NetEase mirror image has been relatively stable.

After modifying the default image repository, you need to restart docker to take effect:

Service docker restart

Use

Start docker

Service docker start

Boot self-start

Sudo chkconfig docker on

Stop docker

Service docker start

List of local images

Docker images

Use the images command to check and find that there are no mirrors in the current local area.

Search

Docker search hello

The following results are all the images we searched for related to "hello"

Pull the image

Docker pull hello-world

We tried to pull the image named "hello-world" from the repository

After the pull is successful, use the docker images command to check and find that the image has been pulled locally.

Run Mirror

Docker run hello-world

After running, the image will output the following information:

Image renaming

Docker tag hello-world hw

We renamed the previously downloaded "hello_world" image to "hw", and using the images command to view it, we will find that there is already an additional image named "hw" in the list.

Delete Mirror

Docker rmi hello-world

We have deleted the image named "hello_world". The parameters after rmi can also be image short id, image length id, image name or image summary.

Unloading

List installation packages

Yum list installed | grep docker

Delete installation package

Yum-y remove docker-engine.x86_64yum-y remove docker-engine-selinux.noarch

Delete images / containers, etc.

This is the end of the article rm-rf / var/lib/docker on "how to install and use Docker in CentOS7". Thank you for reading! I believe you all have a certain understanding of "how to install and use Docker in CentOS7". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Mirror code script command official knowledge warehouse content accelerator article system NetEase search run greatness success value information reason parameter Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB NVidia Shulou Information Docker