Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to install Docker on CentOS system

Shulou Source: shulou.com Published: 2022-06-01 08:15:09 09月11日 Update

This article introduces the relevant knowledge of "how to install Docker on the CentOS system". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Docker is an open source tool that makes it easy to create and manage Linux containers. Containers are like lightweight virtual machines and can be started or stopped in milliseconds. Docker helps system administrators and programmers develop applications in containers and can be extended to thousands of nodes.

The main difference between containers and VM (virtual machines) is that containers provide process-based isolation, while virtual machines provide complete isolation of resources. It may take a minute for the virtual machine to start, while the container only takes a second or less. The container uses the kernel of the host operating system, while the virtual machine uses a separate kernel.

One of the limitations of Docker is that it can only be used on 64-bit operating systems.

In this article we will discuss how to install docker in CentOS 7.x.

Installation of Docker in CentOS 7

The Docker package is already included in the default CentOS-Extras software source. So to install docker, simply run the following yum command:

The code is as follows:

[root@localhost ~] # yum install docker

Start the Docker service

After the installation is complete, use the following command to start the docker service and set it to boot:

The code is as follows:

[root@localhost ~] # service docker start

[root@localhost ~] # chkconfig docker on

(LCTT translation note: the old sysv syntax is used here, such as the new systemd syntax supported in CentOS 7, as follows:

The code is as follows:

[root@localhost ~] # systemctl start docker.service

[root@localhost ~] # systemctl enable docker.service

)

Download the official CentOS image locally (LCTT note: because the Docker is walled:-<, please use the http://docker.cn image, thanks to @ Ma Quanyi's image. )

The code is as follows:

[root@localhost ~] # docker pull centos

Pulling repository centos

192178b11d36: Download complete

70441cac1ed5: Download complete

Ae0c2d0bdc10: Download complete

511136ea3c5a: Download complete

5b12ef8fd570: Download complete

Confirm that the CentOS image has been obtained:

The code is as follows:

[root@localhost ~] # docker images centos

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Centos centos5 192178b11d36 2 weeks ago 466.9 MB

Centos centos6 70441cac1ed5 2 weeks ago 215.8 MB

Centos centos7 ae0c2d0bdc10 2 weeks ago 224 MB

Centos latest ae0c2d0bdc10 2 weeks ago 224 MB

Run a Docker container:

The code is as follows:

[root@localhost] # docker run-I-t centos / bin/bash

[root@dbf66395436d /] #

We can see that the CentOS container has been started, and we have got the bash prompt. In the docker command, we used the "- I capture standard input and output" and "- t assign a terminal or console" options. To disconnect from the container, enter exit.

The code is as follows:

[root@cd05639b3f5c /] # cat / etc/redhat-release

CentOS Linux release 7.0.1406 (Core)

[root@cd05639b3f5c /] # exit

Exit

[root@localhost ~] #

We can also search containers based on Fedora and Ubuntu operating systems.

The code is as follows:

[root@localhost ~] # docker search ubuntu

[root@localhost ~] # docker search fedora

Displays a list of currently running containers

That's all for "how to install Docker on a CentOS system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Container code system image operating system command run content kernel more knowledge program translation syntax software facet service management input output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Redmi vpn MariaDB Huawei