This article describes how to install Docker on CentOS 7. Docker is like a lightweight virtual machine, which makes it easy to create and manage Linux containers. It can be started or stopped in milliseconds. Docker helps system administrators and programmers develop applications in containers and can expand to thousands of nodes.
The main difference between containers and VMS is that containers provide process-based isolation, while virtual machines provide full isolation of resources. The virtual machine may take one minute to start, while the container only takes one second or less. Containers use the kernel of the host operating system, while virtual machines use an independent 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.
Docker installation in CentOS 7
The Docker package is included in the default CentOS-Extras software source. To install docker, run the following yum command:
[Root @ localhost ~] # Yum install docker
Start the Docker service
After the installation is complete, run the following command to start the docker service and set it to boot:
[Root @ localhost ~] # Service docker start
[Root @ localhost ~] # Chkconfig docker on
(LCTT note: The old sysv syntax is used here, for example, the new systemd syntax supported in CentOS 7 is as follows:
[Root @ localhost ~] # Systemctl start docker. service
[Root @ localhost ~] # Systemctl enable docker. service
)
Download the official CentOS image locally (LCTT Note: Because Docker is Walled:-<, so please use the image of the http://docker.cn, thanks @ Ma Quan 1 image. )
[Root @ localhost ~] # Docker pull centos
Pulling repository centos
192178b11d36: Download complete
70441cac1ed5: Download complete
Ae0c2d0bdc10: Download complete
2017136ea3c5a: Download complete
5b12ef8fd570: Download complete
Confirm that the CentOS image has been obtained:
[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:
[Root @ localhost ~] # Docker run-I-t centos/bin/bash
[Root @ dbf66395436d/] #
We can see that the CentOS container has been started and we get a bash prompt. In the docker command, we use the "-I capture standard input and output" and "-t assign a terminal or console" options. To disconnect from the container, enter exit.
[Root @ cd05639b3f5c/] # cat/<span style = "width: auto; height: auto; float: none; "id =" 0_nwp "> <a style =" text-decoration: none; "mpid =" 0 "target =" _ blank "href =" http://cpro.baidu.com/cpro/ui/uijs.php? C = news & cf = 1001 & ch = 0 & di = 128 & fv = 15 & jk = 3f02a9bcc6ed33e5 & k = etc & k0 = etc & kdi0 = 0 & luki = 2 & n = 10 & p = baidu & q = 06011078_cpr & rb = 0 & rs = 1 & seller_id = 1 & sid = e533edc6bca9023f & ssp2 = 1 & stid = 0 & t = tpclicked3_hc & tu = u1922429 & u = http % 3A % 2F % 2 Fwww % 2Eadmin10000% 2 Ecom % 2 Fdocument % 2F5556% 2 Ehtml & urlid = 0 "id =" 0_nwl "> <span style = "color: # 0000ff; font-size: 14px; width: auto; height: auto; float: none; "> etc </span> </a> </span>/redhat-release
CentOS Linux release 7.0.1406 (Core)
[Root @ cd05639b3f5c/] # exit
Exit
[Root @ localhost ~] #
We can also search for containers based on the Fedora and Ubuntu operating systems.
[Root @ localhost ~] # Docker search ubuntu
[Root @ localhost ~] # Docker search fedora
Display the list of currently running containers