Docker use and common actions (the mirroring operation of the container)

Docker is an icon whale stuff actually knew a long time ago but has not Docker a depth exposure ( because I think may be more difficult
this time to learn the system a little bit about the way records

I. Overview

Docker is an open source application container engine is a lightweight container technology
is similar to a virtual machine but not a virtual machine to achieve the performance and resource isolation Docker virtual machine is much higher than the virtual machine (anyway a lot of benefits

Docker main scenarios:

If a person you want to install Windows native system installation also need to download additional software such as QQ micro letter, etc. also need to configure
the other people have to install Windows native system, then the same installation also need to download additional software such as QQ micro letter, etc. also need to be configured
Therefore there will be a Windows system image:
a man finished installing Windows native system installed over the other and then packaged software configured
another person directly mounted mirror system is installed over there, including those configured the stuff packaged software will have
the same often also need to install the server environment in a variety of development or operation and maintenance of process
such as MySQL Redis Tomcat, etc.
in particular, there are many servers to a mounting also be configured in one of today's distributed clusters too cumbersome trend

So the solution to:

Docker allows developers to package their applications and dependencies to a lightweight portable container
is then posted to any of the popular Linux machine can achieve virtualization

Docker support will be compiled into a single software image (as mirrored windows system) then check the configuration of various software in the mirror
so I have time Redis MySQL Mirror Mirror Mirror Tomcat and other software needed to mirror the corresponding direct download to
the other users in the mirror after the release went out this image can be used directly placed directly in the mirror to run Docker in
the run up mirror has a term called container
Example: MySQL MySQL vessel had run after the mirror is in MySQL the in container runs
are between each container isolation mechanism sandbox does not have any interface between them and the vessel performance overhead is very low


Second, the core concept

  • Docker host (Host): the machine is installed Docker
    Docker is mounted directly on top of the operating system, either Windows or Linux or OS can be installed
  • Docker client (Client): connecting the host Docker thus operate
    with a command line interface, a graphical manner well
  • Docker warehouse (Registry): used to save all kinds of packaged software image
    has also set up a public warehouse private warehouse
  • Docker mirror (Images): software packaged packet
    stored in the warehouse in Docker
  • Docker container (Container): Examples of the image after starting i.e., the container
    vessel is or a group of applications run independently
    , for example, run a Tomcat container is run Tomcat

Docker's also very simple

manual:

  • 1 , the installation Docker
  • 2 , to download the desired image Docker warehouse to the machine
  • 3 , and then to run directly Docker mirror
    a mirror operation will produce a container
    run several containers have several mirrors
  • 4 , the containers start and stop configuration, and so
    on containers of start and stop of the target software is to start and stop

Third, the common operations

1, the installation and use

Before you install the kernel first needs to see: uname -r
Docker require kernel version higher than 3.10
if the machine is too low kernel need to upgrade the kernel:yum update

Then is to install the Docker:

yum install docker

After installing Docker Docker View version (version):

docker -v

Start Docker (Centos7 writing):

systemctl start docker

Note: Job for docker.service failed because occur if the start Docker the control process exited with error code See "systemctl status docker.service" and "journalctl -xe" for details..
Solutions to see my other article: Perfect Docker start to solve the virtual machine abnormal Job for docker.service failed because the control process exited with error code.

The Docker to boot:

systemctl enable docker

Stop Docker:

systemctl stop docker

2, the mirroring

✧, you first need to search for a mirror:
docker search 镜像关键字

Example:docker search mysql

The default is to Docker Hub search (but sometimes very slow after all foreign websites
Here Insert Picture Description
and then there will be a lot of results meaning of these fields are:
NAME : image name
the DESCRIPTION : Mirror Description
STARS : concern that the number (k units similar to the Github star point is equivalent to how many people praise)
OFFICIAN : whether the official mirror
AUTOMATED : whether the automatic configuration of mirrors (that is downloaded over automatically configure)

✧, when the selection of a suitable image to the next is to download / pull mirrored:
docker pull 镜像名:tag

Image name without a mirror with docker.io such as the name of docker.io/mysql then mirrored mysql is the name of the
course, the full name will do
this: tag is an optional tag represents the tag that is the software version number
, then untagged default is latest That is the latest

If the error specify the mirror repository: docker pull 镜像仓库名/镜像名:tag
specifically I see another blog: solve Docker pull in when the error Get https://registry-1.docker.io/v2/: net / http: request canceled (Client.Timeout e
Here Insert Picture Description

✧, then downloaded to a local mirror can list all of the local mirror:
docker images

Here Insert Picture Description

✧, which mirrored last if do not want the image can be deleted:
docker rmi 镜像id(IMAGE ID):版本号(TAG)

(rmi:remove image)
Here Insert Picture Description

3, container operation

Use process: get imaging software -> Run mirrored produce container get real software
that is mirrored equivalent of the installer When you run the installer software will generate real running (probably not appropriate analogy is not how you install the program 2333 will tell you to run automatically
so that when after the image is downloaded good then you need to start a container according to the mirror

✧, first run container:
docker run --name 容器名 -d 镜像名

E.g:docker run –name myredis –d redis

If the image is not downloaded from the official repository of the need to bring the full name (case on the picture below that is the case)

Note :

  • -Name : custom container name (or not specified not specified, the default name)
  • -d : background
  • name-Image : assign mirror names to run

Want to start a few times to perform
Here Insert Picture Description

✧, then you can view the container:

Check the operation of the vessel

docker ps 

View all together -a container (a: all)

docker ps -a

Here Insert Picture Description
So I ran the same effect as a

✧, when the container is not Bootable container:
docker start 容器名/容器id

Here Insert Picture Description

✧, if you want to stop the container:
docker stop 容器名/容器id

Here Insert Picture Description

✧, delete container:
docker rm 容器id
✧, port mapping

Allow external access to a remote server Docker in the port

-p 服务器的端口:容器中的端口

Note : This parameter to be added when the docker run
to Tomcat as an example: docker run -d -p 8888:8080 docker.mirrors.ustc.edu.cn/library/tomcat
you want to perform a few times to start (of course not the same as each port must)
Here Insert Picture Description
Tomcat start successfully
if the error must shut down the server's firewall or open the specified port

✧, view container logs
docker logs 容器名/容器id

Here Insert Picture Description

✧, into the interior of the container
docker exec -it  容器id  bash

Note: The course can also be changed to bash inside the container directory
Exiting input exitto


Published 174 original articles · won praise 5 · Views 240,000 +

Guess you like

Origin blog.csdn.net/Piconjo/article/details/105045675