Installation of Docker under CentOS6.5 and problems encountered and simple use

Source: Internet
Author: User
Tags docker ps docker run

Docker is an open-source application container engine that makes it easy to create a lightweight, portable, self-sufficient container for any application. Using Linux lxc, AUFS, go language, cgroup to realize the independence of resources, can easily realize the isolation of files, resources, networks, and its ultimate goal is to achieve similar PAAs platform application isolation.

Docker's notable features:

    • File system isolation: Each process container runs in a completely separate root file system.

    • Resource isolation: system resources, such as CPUs and memory, can be assigned to different containers, using Cgroup.

    • Network isolation: Each process container runs on its own network space, virtual interface, and IP address.

    • Logging: Docker collects and records the standard flow (Stdout/stderr/stdin) for each process container for real-time retrieval or bulk retrieval.

    • Change management: Changes to the container file system can be submitted to the new image and reused to create more containers. No need to use templates or manual configuration.

    • Interactive Shell:docker can assign a virtual terminal and associate it to the standard input of any container, such as running an interop shell once.

Docker is typically used for the following scenarios:

    • Automated packaging and publishing of Web applications;

    • Automated testing and continuous integration, release;

    • Deploy and tune databases or other back-end applications in a service-oriented environment;

    • Build your own PAAs environment by compiling from scratch or by extending your existing OpenShift or cloud foundry platform.

This article describes how to install Docker in a Redhat/centos environment. Official documentation requires at least 3.8 Linux kernel, and Docker can only run on a 64-bit system. Since the kernel version of RHEL6 and CentOS6 is 2.6, the kernel must be upgraded first.

Below is an example of CentOS6.5 (64-bit), which describes the following Docker installation steps and how to use them:

First, upgrade the kernel (with Aufs module, remember to upgrade, otherwise there will be a lot of strange problems, it is recommended to install with Yum)

1. Yum Install the 3.10 kernel with aufs module (or download kernel manual installation here:http://down.51cto.com/data/1903250)

123 cd/etc/yum.repos.d wget http://www.hop5.in/yum/el6/hop5.repoyum installkernel-ml-aufs kernel-ml-aufs-devel

2, modify the GRUB main profile/etc/grub.conf, set default=0, indicating that the content under the first title is the default startup kernel (typically the newly installed kernel is in the first position).

3, restart the system, this time your kernel has been successfully upgraded.

12 [[email protected] ~]# uname -r3.10.5-3.el6.x86_64

To see if the kernel supports AUFS:

12 [[email protected] ~]# grep aufs /proc/filesystemsnodev    aufs

Second, install Docker

    1、首先关闭selinux:
12 setenforce 0 sed-i ‘/^SELINUX=/c\SELINUX=disabled‘/etc/selinux/config

2. Docker-io package has been provided in Fedora Epel source, download and install Epel:

12 rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpmsed-i ‘s/^mirrorlist=https/mirrorlist=http/‘/etc/yum.repos.d/epel.repo

3. Yum Installation Docker-io:

1 yum -y installdocker-io

4. Start Docker:

1 service docker start

5. View the Docker version:

To view Docker logs:

1 cat/var/log/docker

Third, the use of Docker commands

1. Enter the Docker command directly to view all options and commands.

To view the detailed use of a command: Docker command--help

2. Search for available Docker images: Docker search NAME

3. Download Image: Docker pull Name[:tag]

For example, get the latest CentOS Image: Docker pull Centos:latest

Note: This is to write the full image name that you searched for with Docker search. 4. View the installed Image: Docker images [NAME]

5. Run the command in the Docker container: Docker run IMAGE [command] [ARG ...]

The Docker Run command has two parameters, one for the mirror name and one for the command to run in the mirror.

Note: Image=repository[:tag], if the image parameter does not specify a mirrored tag, the default tag is latest.

Output "Hello word" in the image you just downloaded: Docker run CentOS Echo ' Hello world! '

6. List containers: Docker ps-a

View the most recently generated container: Docker ps-l

To view a running container: Docker PS

7, display the standard output of the container: Docker logs Containerid

There is no need to copy the complete ID, usually the first three to four characters.

8, install new programs in the container, such as install Ifconfig command (centos7 default no ifconfig): Docker run CentOS Yum install net-tools-y (stuck, with another command below)

If Yum does not specify the-y parameter, the yum command enters interactive mode and requires the user to enter a command to confirm that the interaction cannot be responded to in the Docker environment. But using the-i-t parameter of Docker run responds to this interaction, and the user can enter commands such as Docker run-i-T CentOS Yum install Net-tools

9. Save changes to the container and generate a new image: Docker commit Containerid [Repository[:tag]]

The repository parameter can be a new image name, or an old mirror name, or overwrite the old image if it is the same as the old mirror name and tag.

10. Stop a running container: Docker stop Containerid

The default waits 10 seconds before killing the specified container. You can use the-t parameter to set the wait time.

11. View container or mirror details: Docker inspect containerid| IMAGE

The parameter can be either the ID of the container or the mirror name (Name:tag).

12. Delete Container: Docker rm Containerid

View all containers Id:docker Ps-a-Q

Remove all containers: Docker RM $ (Docker ps-a-Q)

13. Remove Image: Docker RMI image

14. View Docker information, including the number of containers and images, the kernel version, and more.

Iv. operations to create a container and log in

1. Create a new container and log in: Docker run-i-T Image/bin/bash

Using image to create container and enter interactive mode, the login shell is/bin/bash, and now it is free to manipulate the container. Finally, exit the container with exit.

Note: If the image parameter does not specify tag, the default tag is latest.

2. Start an exit Container: Docker start Containerid

3. Attach to the running container: Docker attach Containerid

Transfer from http://blog.csdn.net/wuzhilon88/article/details/41621285

Installation of Docker under CentOS6.5 and problems encountered and simple use

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.