docker overview of the installation and operation of the vessel

Traditional virtualization
traditional virtualization Step
1, install virtualization software and virtualization management software
2, create a virtual machine
3, to the virtual machine installation os
4, inside the virtual machine than the application (http, db like application)
Virtual tradition oriented features
1, between VM and VM is completely isolated, and the virtual machine must be installed os
2, the application is running environment is built on top of the operating system
3, application migration very bulky
traditional virtualization has been unable to meet current agile development methods, VM ways lead to inconsistent development and production environments, after completion of the test version needs to re-build environment.
Docker
Docker is a container of engine tool, the most important is the life cycle management of the container, create the container, container management, management mirroring. Container concept is no operating system, the container is initiated by image. When you create the image and start a container by one, in the process container we have started. Once the process quit unexpectedly inside the container, the container will die. That process vessel, the process is disfigured dead. Isolation between the container and the container through the namespace (namespace separator), for the Linux operating systems must exist namespace, without additional installation.
A complete docker consists of four parts:
docker Client Client
docker daemon daemon
docker image mirrored
docker container vessel
docker features
an isolated environment (system, network, file system) and application
to solve the problem of dependence and version
easy distribution out of the box
Nodes and vessels rapid expansion
mirroring simple and convenient, easy to manage.
Isolation
(isolation between the groups) by cgroup (the use of isolation and tracking resources) and namespace to achieve lightweight process isolation.
The corresponding process running in the container, the exclusive own a system.
Between the container network, documents and other resources are isolated from each other.
Version and dependence
under the traditional model, a number of different versions of the environment or the project needs to be deployed on different machines, deploy and manage complex tedious post-maintenance.
Docker by using multiple different versions or mirrored environments can run simultaneously on a single machine without disturbing each other, easy deployment and ongoing maintenance.
Distribution and use of
a mirror can import, export, upload a variety of ways mirroring warehouse for distribution.
Used on the system directly launched docker docker run to start mirroring, requires no special configuration.
Expansion
vessel dilatation easy
expansion node can simply install and launch docker
mirroring
mirror soul dockerfile
use dockerfile control instruction
based on the linux commands are easy to understand quickly get started
easily customized and modified
scenarios
automation packaged web applications and publish
automated testing and continuous integrated publishing
application services, such as mysql, redis such as rapid deployment docker achieved by
k8s private cloud
installation environment
system: centos 7.4 minimal
Partition:
/ XFS 500M Boot
the swap without the use of
/ all of the remaining
mounting docker
. 1, as an engine mounting tool container docker
yum the install docker -Y
2, the service start docker
systemctl enable docker
systemctl Start docker
. 3, a search image
docker to create and start through image container, image in the image repository. Warehouse warehouse is divided into public (such as docker.io) and private warehouses. By default docker will visit public warehouse, docker will pull the image of public warehouses.
docker search centos
search public warehouse containing image centos keyword.
4, download image
Docker pull docker.io/centos
pull i.e. pulled from a public repository to the local image.
5. Check local Image
Docker ImagesRF Royalty Free
6, start the container
Docker RUN docker.io/centos -d
-d backend that is running
7 to view the container
Docker PS
Dockers PS -a
no result that is not running the vessel, likely reason is that the container within no process.
The implementation process from an executable file.
Use docker to create a container through an image, there will be a process inside the container, embedded in a executable file (command) within the image. To create a container by the time this image, it will execute the executable file, resulting in front-end process.
docker.io/centos This image contains no executable file, there is no trigger an executable file. So when you create the container, the container immediately quit.
RUN -ti docker.io/centos Docker / bin / the bash
-ti interactive operation
8, the process in the vessel See
Docker Top
Docker Top D54
D54 vessel short ID
. 9, see the container parameters
Docker D54 Inspect
10, to view the container ID
Docker PS -q
11, see container logs
Docker logs D54
12, delete container
docker rm d54
can not be deleted if a container is in the running state.
RM $ Docker (Docker -qa PS)
13, stop the container
docker stop d54
container after stopping may be removed.
14, operation of the vessel
yum to intall Tools -Y-NET
15, into the container
-ti Exec 35d Docker / bin / the bash
16, the container designated start parameter
specifies the host name of the container
docker run -d -t --hostname = servera.example.com docker.io/centos
specified DNS
Docker RUN -d -t - hostname = serverb.example.com --dns 8.8.8.8 --dns 4.4.4.4 docker.io/centos
specified IP
Docker RUN = -d -t --hostname serverc.example.com - DNS - DNS 8.8.8.8 4.4.4.4 --ip = 192.168.0.222 docker.io/centos
defined variables
docker run -d -e name = test -e mYSQL_USER = root -ti docker.io/centos / bin / bash
container automatically restart after exiting the container
docker run -d --restart = always -e mYSQL_USER = root -ti docker.io/centos / bin / bash
automatically restart after 3 failed not restart
docker run -d --restart = on-failure : 3-e mYSQL_USER = root -ti docker.io/centos / bin / bash
view the boot help
docker run --help

Guess you like

Origin www.cnblogs.com/yinshoucheng-golden/p/10959978.html