Docker consists of three basic concepts
Image (Image)
Container (Container)
Warehouse (Repository)
By understanding these three concepts, you understand the entire life cycle of Docker.
Docker image
A Docker image is a read-only template.
For example, an image can contain a full Ubuntu operating system environment with only the Apache or other applications needed by the user installed.
Mirroring can be used to create Docker containers.
Docker provides a very simple mechanism for creating mirrors or updating existing images, and users can even download a
A good image to use directly.
A container is a running instance created from a mirror. It can be started, started, stopped, deleted. Each container is a mutually isolated, secure platform.
You can think of a container as a simple version of the Linux environment (including root user rights, process space, user space, and network space) and run in its
Applications in the.
Note: The mirror is read-only, and the container creates a writable layer at the top level when it starts
Docker container
Docker uses containers to run applications. It can be started, started, stopped, deleted. Each container is a mutually isolated, secure platform.
You can think of a container as a simple version of the Linux environment (including root user rights, process space, user space, and network space) and run in its
Applications in the.
* Note: The image is read-only and the container creates a writable layer at the top level when it is started.
Docker Warehouse
Warehouses are places where image files are centrally stored. Sometimes the warehouse and the warehouse registration server (Registry) are confused, not strictly differentiated. Actual
, the warehouse registration server often holds multiple warehouses, each of which contains multiple mirrors, each with a different label (tag).
Warehouses are divided into public and private warehouses (both). The largest public warehouse is the Docker Hub, which stores a large number
Images for download by users. Domestic public warehouses, including Docker pool, can provide more stable and fast access for mainland users.
Of course, users can also create a private warehouse within the local network. Once the user has created their own image, they can use the push command to upload it
To a public or private repository so that the next time you use the mirror on another machine, you just pull it off the warehouse.
Note: The concept of a Docker repository is similar to Git, where a registered server can be understood as a managed service such as GitHub.
First, upgrade the kernel (with AUFS module)
1. Yum Install the 3.10 kernel with aufs module (or download kernel manual installation here: http://down.51cto.com/data/1903250)
cd/etc/Yumwget http://www.hop5.in/yum/el6/hop5.repoYum Install kernel-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 (general
The newly installed kernel is in the first position)
# vi/etc/grub.conf
# grub.conf generated by Anaconda
#
# Note that you don't have the to rerun grub after making changes to the This file
# notice:you has a/boot partition. This means
# all kernel and INITRD paths is relative to/boot/, eg.
# root (hd0,0)
# kernel/vmlinuz-version RO root=/dev/mapper/vmvg-root
# initrd/initrd-[generic-]version.img
#boot =/dev/vda
Default=0
Timeout=5
Splashimage= (hd0,0)/grub/splash.xpm.gz
Hiddenmenu
Title CentOS (3.10.5-3.el6.x86_64)
Root (hd0,0)
kernel/vmlinuz-3.10.5-3.el6.x86_64 ro root=/dev/mapper/vmvg-root rd_no_luks lang=en_us. UTF-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto rd_lvm_lv=vmvg/root rd_lvm_lv=vmvg/swap KEYBOARDTYPE=pc Keytable=us RD_NO_DM RHGB quiet
Initrd/initramfs-3.10.5-3.el6.x86_64.img
Title CentOS (2.6.32-431.el6.x86_64)
Root (hd0,0)
kernel/vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vmvg-root rd_no_luks lang=en_us. UTF-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto rd_lvm_lv=vmvg/root rd_lvm_lv=vmvg/swap KEYBOARDTYPE=pc Keytable=us RD_NO_DM RHGB quiet
Initrd/initramfs-2.6.32-431.el6.x86_64.img
Then reboot the machine kernel upgrade successfully
# Uname-r
3.10.5-3.el6.x86_64
3. Upgrade Device-mapper-libs, if you do not upgrade, run docker-d will be missing the libdevmapper.so.1.02 class library situation:
Yum Upgrade Device-mapper-libs
Second, install Docker
1. First Turn off SELinux:
0 sed ' /^selinux=/c\selinux=disabled ' /etc/selinux/config
2. Docker-io package has been provided in Fedora Epel source, download and install Epel:
RPM-IVH http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpmsed ' s/^mirrorlist=https/mirrorlist=http/ ' /etc/yumRepos.d/epel.repo
3. Yum Installation Docker-io:
Yum Install Docker-io
4. Start Docker:
Service Docker Startchkconfig Docker on
5. Verify that Docker is installed successfully:
# DockerInfoContainers:0Images:0Storage driver:devicemapper Pool name:docker-253:0-526372-Pool Pool Blocksize:65.54KB backing Filesystem:extfs Datafile:/dev/loop0 Metadatafile:/dev/loop1 Data Space used:305.7MB Data Space total:107.4GB Data Space Available:63.39GB Metadata Space used:733.2KB Metadata Space total:2.147GB Metadata Space Available:2.147GB Udev Sync supported:trueDeferred removal Enabled:falseData Loopfile:/var/lib/docker/devicemapper/devicemapper/data Metadata Loopfile:/var/lib/docker/devicemapper/devicemapper/metadata Library Version:1.02.117-rhel6 ( .-Geneva- on) Execution Driver:native-0.2Logging Driver:json-fileKernel Version:3.10.5-3. el6.x86_64operating System:<unknown>CPUs:4Total Memory:7.812Gibname:nh-test- -Id:jv4m:gch5:qolj:34wt:mqkm:mn5t:bhso:egui:4pkh:u7q3:oboo:7whmwarning:no swap limit support
6. View the Docker version:
# docker-version
Client version:1.7.1
Client API version:1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
Os/arch (client): LINUX/AMD64
Server version:1.7.1
Server API version:1.19
Go version (server): go1.4.2
Git commit (server): 786b29d/1.7.1
Os/arch (server): LINUX/AMD64
Third, Docker common commands
View version: Docker-v
View Help information: Docker
Search for images in the official warehouse: Docker search CentOS
View local Image: Docker images
Download the warehouse image to Local: Docker pull Centos:latest
Upload local image to warehouse: Docker push Name[:tag]
To save the image as a tar file: Docker save-o tar file mirroring ID/Mirror Tag
To load a tar file as a mirror: Docker load-i tar file
Modify image tag:docker Tag Image ID Mirror tag
Remove Image: Docker RMI image ID/Mirror tag
Make Image: Docker build-t centos:autosshd-< Dockerfile.txt
Dockerfile.txt:
dockerfile.txt:FROM Centosmaintainer YH, http://yuanhuan.blog.51cto.comRUNYum Install passwdOpenSSL Openssh-server-YrunEcho '123456'|passwd--stdin RootrunSsh-keygen-q-t Rsa-b2048-f/etc/SSH/ssh_host_rsa_key-n"'RUNSsh-keygen-q-t ecdsa-f/etc/SSH/ssh_host_ecdsa_key-n"'RUNsed-I.'/^session\s\+required\s\+pam_loginuid.so/s/^/#/'/etc/pam.d/Sshdrunmkdir-p/root/.SSH&&ChownRoot.root/root &&chmod the/root/.SSHEXPOSE ACMD IP Addrlseth0 |awk '{print $}'|Egrep-O'([0-9]+\.) {3} [0-9]+';/usr/sbin/sshd-d
View image history: Docker historical Image ID/mirror tag
Create container: Docker run-d--name= container name Mirror ID/Mirror tag
Start container: Docker start container name/container ID
Viewing containers: Docker PS
Restart container: Docker restart container name/container ID
Stop container: Docker stop container name/container ID
Delete Container: Docker RM container name/container ID
Pause container: Docker pause container name/container ID
Recovery container: Docker unpause container name/container ID
Execute command: Docker exec-ti container name/container Id/bin/bash
Get container log: Docker logs container name/container ID
Reference Documentation:
Http://www.centoscn.com/image-text/install/2014/1128/4202.html
Http://www.mamicode.com/info-detail-891132.html
https://docs.docker.com/engine/installation/linux/centos/
centos6.5 Installing Docker