Docker three elements


what

build, ship and run any app anywhere
Docker is designed to avoid a series of problems caused by inconsistencies between development and production environments during the process of program delivery and deployment between development engineers and operations engineers. Through docker, the development engineer packages the program code, running system, software version, description document and so on in a image file, and passes the image file to the operation and maintenance engineer for deployment. For example, if you buy a fish tank with water in it from a pet store, the fish can live in your home without any other operation.


At present, there is no need to discuss the struggle between docker and virtual machine, because major Internet companies are using docker technology, and can expand capacity in a short time, we can know that in the current high concurrency business scenario, from practicality and convenience, virtual machine is unable to defeat docker.

Simply, docker’s centos image is only 200MB, while the virtual machine image is about 2GB. Docker makes use of the resources of the host and only copies the Linux kernel, and docker is no need Hypervisor ,which can be said to be a stripped-down version of the virtual machine

software architecture


Focus on understanding the three elements

How

Docker has many commands, which are not complicated. Just like Linux commands, it is recommended to find them on the official website and practice them a lot
docker images
docker run [options]
docker build [options]
and so on …

Docker image

base on UnionFS
image = fs1 + fs2 + … + fn
It looks like an image is a file system, but it’s actually an image that’s made up of layers of file systems
An available image file is made up of multiple base image layers superimposed, all read-only
For example,
Tomcat image = kernel image + centos image + jdk image + tomcat image

Docker container

docker container = docker run -it image
When docker image is launched, a docker container will be instantiated. In principle, a layer of writable files is added to the top layer of multiple read-only docker images superimposed together, thus generating the running docker container
Docker volumes is very important and you can check the official website for detailed usage

Dockerfile


Dockerfile is similar to a key/value configuration file, which is composed of the construction word in the following figure. Starting From ‘From’, other construction words are listed according to requirements to tell the Dockerfile what to do and what image to generate.


Note the difference between CMD and ENTRYPOINT build words
Dockerfile Docker image Docker container, So what is the relationship between these three
Dockerfile–>(build)–>Docker image–>(run)–>Docker container

Docker Registry

A Repository is a place to store images. Like Node’s NPM; Python PyPi. Currently, Docker officially maintains a public repository, and most of the requirements can be implemented by directly downloading the image from the Docker Hub. Similar to GitHub, in the process of making image or Dockerfile, we draw the base image, i.e. From [base image], From the public library.