Methods and precautions for installing Docker environment on CentOS 7 _docker

Source: Internet
Author: User
Tags docker hub docker run

Official website documents: https://docs.docker.com/engine/installation/linux/centos/, most of the text is copied official documents written, if you are good English, then directly to the official document, if you are not English , then reluctantly look at me this jerky translation ~

All of the following actions are done under the root user

Docker installation requires a 64-bit system and the kernel version is greater than 3.10. Therefore, if it is CentOS, you must install CentOS7.0 or above version.
We are using the CentOS7.2 Mininul.

Uname-r
3.10.0-327.28.3.el7.x86_64

Perform a system-wide software version upgrade before installing Docker:
yum -y update

1. Configure the Yum Software Library

In order to ensure the success of the installation, first use Yum update yum package, which means that I have a lot of Yum package need to update, 1500+ package, if you as I have not updated for a long time, then patiently waiting for it.
Then add the Docker configuration in the Yum Software Library:

# Tee/etc/yum.repos.d/docker.repo <<-' EOF '
[Dockerrepo]
name=docker Repository
baseurl=https:// yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https:// YUM.DOCKERPROJECT.ORG/GPG
EOF

2. Install Docker

With the configuration of the Yum Software Library, the installation becomes unusually simple, just one sentence:

# yum install docker-engine

3. Start Docker
When you are ready, use the start command to start the Docker daemon:

# service docker start

4. Output Hello-world
Programmers seem to have enmity with Hello-world, there is nothing to print someone else, play Docker we are not exceptional at present, first to a Hello-world bar, the basic principle here is to use someone else has been written hello-world mirror, download to the local, and then put him to run up ~

Use the following command:

# docker run hello-world

Then the control end will output similar to the following information, it proves that our Docker environment installation success ~

Here, I failed for the first time ~ show:

Unable to find image ' hello-world:latest ' locally
docker:error response from Daemon:get https://registry-1.docker.i O/v2/library/hello-world/manifests/latest:get https://auth.docker.io/token?scope=repository%3Alibrary% 2fhello-world%3apull&service=registry.docker.io:net/http:tls handshake timeout.
"Docker run--help".

Then I did it again, it should be the reason for the wall, look at the network access has failed ~

Unable to find image ' hello-world:latest ' locally latest:pulling from Library/hello-world c04b14da8d14:pull complete D IGEST:SHA256:0256E8A36E2070F7BF2D0B0763DBABDD67798512411DE4CDCF9431A1FEB60FD9 status:downloaded Newer image for
Hello-world:latest Hello from docker!

This message shows the your installation appears to be working correctly.
 To generate this message, Docker took the following Steps:1 Docker client contacted the Docker.
 2. The Docker daemon pulled the "Hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from this image which runs the executable that produces the output for you are
 Currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run a Ubuntu container with: $ docker run-it Ubuntu bash Share images, automa Te workflows, and more with a free Docker Hub account:https://hub.docker.com for the more examples and Ideas, visit:https://docs.docker.com/engine/userguide/ 

Set to self-start:

chkconfig docker on

To adjust the Docker data directory:

To set up a separate data partition as the Docker data directory, you need to manually move the data from the original directory to the new storage partition, and then mount the new storage partition to the/var/lib/docker directory.

service docker stop

Copy data and hanging partition:

service docker start

4. Create a dedicated Docker group

Docker is required to run with root privileges, but it is still possible to manage Docker services by creating a dedicated user group for a common user with sudo privileges.

Copy Code code as follows:

# Groupadd Docker
# Usermod-ag Docker BJXTB

Exit the current session, log back in and use BJXTB to manage Docker directly:

$ docker run hello-world

To run a Docker container:

[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.

[root@cd05639b3f5c/]# cat/etc/redhat-release
centoslinux release 7.0.1406 (Core)
[root@cd05639b3f5c/] #exit
Exit
[Root@localhost ~]#

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

[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.