(3) Learn dockerDocker Engine is an open source containerization technology used to build and containerize your applications. Docker Engine acts as a client-server application in the following ways:

  • A server dockerd with a long-running daemon.
  • API is used to specify the interface that the program can use to communicate with the Docker daemon.
  • Command line interface (CLI) client docker.
    The CLI uses the Docker API to control or interact with the Docker daemon through scripts or direct CLI commands. Many other Docker applications use the basic API and CLI. The daemon creates and manages Docker objects, such as images, containers, networks, and volumes.

Related concepts

  1. Docker Engine: A C / S application, containing the following components: a long-running daemon, a REST API for commanding the daemon, and a command line interface
  2. Docker Daemon (dockerd): monitor Docker API requests, and can also interact with other Daemons to manage Docker services
  3. Docker Client (docker): used to connect and interact with Daemon, can connect multiple Daemon
  4. Image (image): the template of the container, which can generate multiple instances according to different configurations.
  5. Container: An instance of an image, which can be started / stopped / deleted through the Docker API, and can be connected to multiple networks, hung on multiple storages, and even create a new image in the current state
  6. Docker Compose: A tool for defining and running multi-container Docker applications. Its functions include opening / closing services, viewing the running status of services, outputting service logs, and running one-time commands. The daemon creates and manages Docker objects, such as images, containers, network, volumes
  7. Dockerfile: used to define the application environment, so that the environment can be loaded repeatedly
  8. yml file: a file used to define the services that make up the application, so that the services can run together in an independent environment
  9. Docker Machine: used to install Docker Engine to a virtual host, and you can use related commands to manage these hosts
  10. Swarm mode: used to arrange and deploy multiple Docker containers
  11. k8s: used to deploy and manage containers

Build environment

After the step-by-step installation according to the official installation tutorial (debian), execute docker run hello-world to run the official Hello World example

  1. Docker client connects to Docker daemon
  2. Docker daemon pulls hello-world image from Docker Hub
  3. The Docker daemon creates a new container from the pulled image. The paragraph displayed on the terminal is created from this container
  4. The Docker daemon streams the output to the Docker client, which is displayed on the terminal shown below

The container instance generated by the image file is itself a file, called a container file. That is to say, once the container is generated, there will be two files at the same time: image file and container file. And closing the container does not delete the container file, just the container stops running.

List running containers on this machine

$ docker container ls

List all the containers of this machine, including the containers that are terminated

$ docker container ls --all

Container files that are terminated will still occupy hard disk space and can be deleted using the docker container rm command.

$ docker container rm [containerID]

Dockerfile file: It is a text file used to configure image. Docker generates a binary image file based on this file.

Take the koa-demos project as an example to make your own Docker container

$ git clone https://github.com/ruanyf/koa-demos.git
$ cd koa-demos 

Then, in the root directory of the project, create a new text file Dockerfile and write the following content.

FROM node:8.4
COPY . /app
WORKDIR /app RUN npm install --registry=https://registr

Guess you like

Origin www.cnblogs.com/sy211910/p/12710035.html