CENTOS6.5 under Docker installation and configuration

Source: Internet
Author: User
Tags docker ps

Learn some of the latest trends Docker is a new and good thing.

1 About Docker
Docker provides an envelope (envelope), or container, that can run your application. It was originally an amateur project launched by DotCloud, and was open source in the early days. It attracts a lot of attention and discussion, causing DotCloud to rename it to Docker Inc. It was originally written in the Go language, which is equivalent to a pipeline added to the LXC (LinuX containers,linux container), allowing developers to work at a higher level of concept.
Docker extends the Linux container (Linux Containers), or LXC, with a high-level API that provides a lightweight virtual environment for the process alone. Docker leverages LXC, Cgroups, and Linux's own kernel. Unlike traditional virtual machines, a Docker container does not contain a single operating system, but is run based on the functionality provided by the operating system in an existing infrastructure.
Docker is similar to the concept of virtual machines, but the difference with virtualization technology lies in the following points:
1. Virtualization technology relies on physical CPUs and memory, is hardware-level, and Docker is built on the operating system, leveraging the operating system's containerization technology, so Docker can even run on virtual machines.
2. Virtualized systems generally refer to operating system images, which are more complex, called "systems", while Docker is open source and lightweight, called "containers", and a single container is suitable for deploying a small number of applications, such as deploying a Redis, a memcached.
3. Traditional virtualization technology uses snapshots to save state, while Docker is not only more portable and inexpensive to save, but also introduces a similar source-control mechanism that records the snapshot history of a container, with low switching costs.
4. Traditional virtualization technologies are complex to build systems, require a lot of manpower, and Docker can build the entire container through Dockfile, which is fast to restart and build. More importantly, Dockfile can be written manually so that application developers can guide the system environment and dependencies by publishing Dockfile, which is beneficial for continuous delivery.
5.Dockerfile can create a new container based on a container image that has already been built. Dockerfile can be shared and downloaded through the community, facilitating the promotion of this technology.
Docker works like a portable container engine. It packs the application and all of its dependencies into a virtual container that can run on any Linux server. This greatly improves the flexibility and portability of program operation, whether it's a need for licensing, a public cloud or a private cloud, a bare metal environment, and so on.
Docker is also a cloud computing platform, it uses Linux lxc, Aufu, go language, cgroup to achieve the independence of resources, can easily achieve file, resource, network and other isolation, the ultimate goal is to achieve similar PAAs platform application isolation.
Docker consists of the following:
1. Docker Server Daemon (server daemon), used to manage all containers.
2. Docker command-line client for controlling the server daemon.
3. Docker Image: Find and browse Docker container images.

2 Docker Features

File system isolation: Each process container runs in a completely separate root file system.
Resource isolation: You can use Cgroup to assign different system resources, such as CPU and memory, to each process container.
Network isolation: Each process container runs in its own network namespace, with its own virtual interface and IP address.
Write-time replication: Create a root file system with write-time replication, which makes deployment extremely fast and saves memory and hard disk space.
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.


3 Installing Docker direct Yum installation

Yum-y Install Docker-io


There may be an error to install Epel


Error Warning:

Warning:rpmts_HdrFromFdno:Header V3 rsa/sha256 Signature, key ID 0608b895:nokey

Retrieving Key from File:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6


GPG Key retrieval failed: [Errno] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6



Workaround Installation Epel

RPM-IVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

RPM--import/etc/pki/rpm-gpg/rpm-gpg-key-epel-6

Yum Install-y yum-priorities

And then install it again


modifying configuration information

Vi/etc/sysconfig/docker

Other-args instead: other_args= "--exec-driver=lxc--selinux-enabled"


and start Docker.


Service Docker start or/etc/init.d/docker start


This is the time to execute some commands to see the relevant information

Docker Info: View System (Docker) level information, including managed images, containers number, etc.

Docker version: View the release number of Docker, including client, server, dependent go, etc.


May be out of this is the present error:

FATA[0000] Cannot connect to the Docker daemon. Is ' docker-d ' running on this host?

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/71/A0/wKioL1XVhJeg86hHAABe3PK0ZzE639.jpg "title=" 1.png " alt= "Wkiol1xvhjeg86hhaabe3pk0zze639.jpg"/>

This is because the Docker daemon daemon is not started by default and can be started as prompted


Note the execution of docker-d may cause an error:

WARN[0000] running Linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running Docker. Upgrade your kernel to 3.8.0.

INFO[0000] +job Serveapi (unix:///var/run/docker.sock)

INFO[0000] Listening for HTTP on Unix (/var/run/docker.sock)

Docker:relocation error:docker:symbol Dm_task_get_info_with_deferred_remove, version Base not defined in file Libdevmap per.so.1.02 with link Time reference

Tip The kernel version is too low to run Docker here you can upgrade directly to the prompt version. or upgrade the device mapping library:

Yum Upgrade Device-mapper-libs-y


Last executed Nohup docker-d &

4 Download image


Mirroring can be thought of as a container system with some software, such as CentOS is an official base image, and many mirrors are "derived" from this image, which contains the basic CentOS system.


Search Image: Docker search CentOS


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/71/A4/wKiom1XVh5mQFnPDAARoPCFungg901.jpg "title=" 1.png " alt= "Wkiom1xvh5mqfnpdaaropcfungg901.jpg"/>

Can search for a lot of CentOS images


Download the required Image:

Docker Pull Centos:latest

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/71/A1/wKioL1XVioiSqH5KAACcCcNqK-0883.jpg "title=" 1.png " alt= "Wkiol1xvioisqh5kaaccccnqk-0883.jpg"/>

Docker Pull jdeathe/centos-ssh-apache-php


After the download is complete, you can view the downloaded image directly:

Docker Images: List images

Docker images-a: List all images (including history)

Docker Images--tree: Show all layers of a mirror (layer)

Docker RMI <image Id>: Deleting one or more image


5 Creating a container using mirrors


Docker run image ID or mirror name/bin/echo ' Good job '

Create an interactive container:

Docker run-it image ID or mirror name/bin/bash

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/71/A1/wKioL1XVkn6xcHH6AAMIbr35rlE198.jpg "title=" 1.png " alt= "Wkiol1xvkn6xchh6aamibr35rle198.jpg"/>

(Error Please ignore does not support the Chinese cause ...) It is obvious that the interactive container is directly inside the container, and non-interactive is to execute a command in the container.

Either way, the container is off after it exits.


View Container

Docker PS: List all currently running container
Docker ps-l: List the most recently launched container
Docker ps-a: List all container (including history, running container)
Docker ps-q: List the last Run container ID


6 Start the Container connection container again


Docker Start/stop/restart <container>: Open/Stop/restart container
Docker start [container_id]: Run a container again (including historical container)
Docker attach [container_id]: Connecting a running container instance (that is, the instance must be the start state and multiple windows can attach a container instance at the same time)

Docker exec-it [container_id]/bin/bash: Connecting a running container instance

Docker start-i <container>: Start a container and enter interactive mode (equivalent to start first, in attach)

Docker attach differs from Docker exec:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/71/A5/wKiom1XVlaqh1fYzAANs3JEHtuA082.jpg "title=" 1.png " alt= "Wkiom1xvlaqh1fyzaans3jehtua082.jpg"/>

The container is still running after the exec connection exits, and the container is stopped after the attach connection container exits.



Delete Container

Docker RM <container...>: Delete one or more container
Docker RM ' Docker ps-a-Q ': Remove all container
Docker Ps-a-Q | Xargs Docker RM: Ibid., remove all container


This allows Docker containers to be used.


7 Persistence container (create image with deployed container)

Docker export <container id> >/tmp/export.tar output image file

Cat/tmp/export.tar | Docker Import-export:latest Importing image files

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/71/A2/wKioL1XVnjyRsnvIAAOCH-1VKRI458.jpg "title=" 1.png " alt= "Wkiol1xvnjyrsnviaaoch-1vkri458.jpg"/>

Finally see the Welcome document written before the experiment.




This article from the "New One" blog, reproduced please contact the author!

CENTOS6.5 under Docker installation and configuration

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.