First, Docker introduction:
Docker is an open source tool that makes it easy to create and manage Linux containers. A container is like a lightweight virtual machine and can be started or stopped at a millisecond speed. Docker helps system administrators and programmers develop applications in containers and can scale to thousands of nodes.
The main difference between containers and VMS (virtual machines) is that containers provide process-based isolation, while virtual machines provide complete isolation of resources. The virtual machine may take a minute to start, and the container will take only one second or less. The container uses the kernel of the host operating system, and the virtual machine uses a separate kernel.
One of the current limitations of Docker is that it can only be used on 64-bit operating systems.
Second, the test environment
Test server type: VM virtual machine
Test system: Centos7.1 system core 3.10
Docker version: 1.8.2
ps:centos6.x version installation requires upgrading the kernel to 3.10
Third, install Docker
First turn off SELinux and iptables
And then install Docker.
Yum Install Docker-y
Four, start Docker
After the installation is complete, use the following command to start the Docker service and set it to boot:
[[email protected] ~]# Systemctl start Docker
[[email protected] ~]# Chkconfig Docker on
View Docker Run status
[Email protected] ~]# systemctl status Docker
Stop Docker
Systemctl Stop Docker
Restart Docker
Systemctl Restart Docker
V. View version
Docker-v
VI. Configuration and Management
1. Get the image
Docker Pull CentOS
2. View image
Docker images
Docker images-a: List all images (including history)
[Email protected]_test1 ~]# Docker images-a
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.xxxx.com:5011/c6.4 latest D319001f94f5 9 months ago 431.6 MB
Docker Images--tree: Show all layers of a mirror (layer)
3. Remove the image
Docker RMI <image Id>: Deleting one or more image
4. Create a container using images
Docker run-i-T <image>/bin/bash: Create container with image and enter interactive mode, login shell is/bin/bash
5, for the operation of the container Containe
Docker Start/stop/restart <container_id>: Open/Stop/restart container
Docker attach [container_id]: Connecting a running container instance (must be a start state, multiple windows can attach a container instance at the same time)
Docker start [container_id]: Run a container again (including historical container)
Docker start-i <container>: Start a container and enter interactive mode (equivalent to start first, in attach)
Docker run-i-t-p
Host_port can be omitted, omitting the container_port mapping to a dynamic port.
Note: Using start is to start a container that has already been created, and use Run to open a new container through the image.
6. Exit the container
Exit
7. Delete Container
Docker RM <container...>: Delete one or more container
Docker RM ' Docker ps-a-Q ': Remove all container
Vii. some common commands
Docker logs $CONTAINER _id #查看docker实例运行日志 to ensure proper operation
Docker inspect $CONTAINER _id #docker Inspect <image|container> view underlying information for image or CONTAINER
Docker build <path> Look for a configuration file named Dockerfile under path path, use this configuration to generate a new image
Docker Build-t Repo[:tag] Ibid, you can specify repo and optional tag
Docker Build-< <dockerfile> using the specified dockerfile configuration file, Docker gets the content stdin, using this configuration to generate a new image
Docker Port <container> <container port> See which port is mapped to the specified port on the container, and you can actually see it with Docker PS
Viii. Docker Directory Introduction
Docker default files are placed under the/var/lib/docker path
[[email protected] docker]# ls
Containers/devicemapper/execdriver/graph/init/linkgraph.db Repositories-devicemapper volumes/
Containers Directory storage container (container)
The graph directory holds the image,
The file system layer is stored under the Graph/imageid/layer path so that we can see exactly what is in the file layer and use this hierarchy to clearly see how the layers of the file layer stack up.
Nine, view root password
The root user's password is randomly assigned when the Docker container is started. Thus, the root user's password for the container can be obtained in this way.
Docker Logs container_id 2>&1 | grep ' User: ' | Tail-n1
****************************************************************************************
Ten, some parameters
After you install Docker, you can set some of the Docker's operating parameters before you start
Set the relevant Docker's operating parameters by modifying the/etc/sysconfig/docker file
Options= '--selinux-enabled--insecure-registry docker.xxxxx.com:5011-h 0.0.0.0:2376-h Unix:///var/run/docker.sock- -graph=/data/docker/dockerapp '
Parameter description:
--insecure-registry: Sets the non-secure authentication of the address, which allows the use of certificate authentication without CA authentication.
-H Set TCP listener port number and sock for API calls
--graph: Sets the default mirror and container storage location.
Then, in the local hosts, write the parsing for docker.xxxx.com.
Temporarily for: 172.16.x.x docker.xxxx.com
Then start the Docker service
This article is from the "Small Five Car God" blog, please be sure to keep this source http://linuxtech.blog.51cto.com/3670088/1730523
Docker Installation and configuration management