How to install Docker on a CentOS system

Source: Internet
Author: User
Tags centos docker run

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 at a millisecond rate. Docker helps system administrators and programmers develop applications in containers, and can scale to thousands of nodes.

The main difference between a container and a VM (virtual machine) is that the container provides process-based isolation, while the virtual machine provides complete isolation of the resource. The virtual machine may take a minute to start, and the container needs only one second or less. The container uses the kernel of the host operating system, and 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. Therefore, to install Docker, you only need to 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: 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 mirror to the local (LCTT: Because Docker is:-< by the wall, please use the http://docker.cn mirror, thanks to the @ Ma Quan Mirror. )

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 Mirror has been fetched:

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

To run a Docker container:

The code is as follows:

[Root@localhost ~]# Docker run-i-T Centos/bin/bash

[root@dbf66395436d/]#

As we can see, the CentOS container has been started and we've got the bash prompt. In the Docker command we used the "-I capture standard input and output" and "T-assign a terminal or console" option. 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 for containers based on Fedora and Ubuntu operating systems.

The code is as follows:

[Root@localhost ~]# Docker search Ubuntu

[Root@localhost ~]# Docker search Fedora

Displays the list of containers that are currently running

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.