The original link: https://blog.csdn.net/forezp/article/details/80098675

This series of tutorials is translated into docker document, document address: https://docs.docker.com/, due to some reasons,docker official documents are usually not open, if not open, after installing Docker, you can pull the image of docker document to run locally. After installing Docker, type the following command:

docker run -it -d -p 4000:4000 docs/docker.github.io:latest

To see the docker document, open localhost:4000 in your browser.

This series of tutorials was translated in April 2018 as Docker version V18.03

Docker related concepts

Docker is a platform for developers and operators to develop, publish and run applications in containers. Using Linux containers to deploy applications is called containerization. Containers are not a new concept, and their advantage is that it is easy to release an application.

Containerization has become very popular because it has the following advantages:

  • Flexibility: Even the most complex applications can be containerized.
  • Lightweight: Containers maximize utilization and sharing of the host kernel.
  • Interchangeable: You can deploy updates and upgrades in real time.
  • Convenience: You can build your application locally, deploy it to the container cloud, and run it anywhere.
  • Extensible: You can increase and automatically distribute the number of containers.
  • Stackable: You can stack services vertically and instantaneously.

Images and Containers

The container is started by running an image. An image is an executable package that contains everything you need to run your application – code, runtime libraries, environment variables, and configuration files.

A container is a runtime instance of an image, and a container is an image running in memory (that is, an image has state, or a user process). You can view a series of running containers by tapping a Docker PS like a Linux environment.

Containers and virtual machines

A container runs locally on a Linux service and shares the host kernel with other containers. It runs in a separate process and has a smaller footprint and is more lightweight than other executable processes, such as virtual machines.

A virtual machine (VM), by contrast, runs a full “guest” operating system that virtually accesses host resources through a hypervisor. In general, virtual machines provide an environment that requires more resources than most applications.

Prepare your Docker environment

Please see the official website to install Docker.

Centos installation:

yum -y install docker-io

Activation:

service docker start

See the official website for more system installations.

Test the Docker version

  1. Run the docker –version command and make sure your version of Dokcer supports the command:
Docker --version docker version 17.12.0-ce, build c97c6d6Copy the code
  1. Run the docker info (docker version does not have –) command to view more docker installation information.
Docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 17.12.0 -CE Storage Driver: overlay2 ...Copy the code

Docker is successfully installed

  1. Run a simple Docker image (Hello World) to test the docker installation.
docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

Copy the code

2. List the Hello World images downloaded on your machine.

docker image ls
Copy the code
  1. Lists exiting Hello-world containers (generated by the image). If it is still running, the –all option is not required:
docker container ls --all

CONTAINER ID     IMAGE           COMMAND      CREATED            STATUS
54f4984ed6a8     hello-world     "/hello"     20 seconds ago     Exited (0) 19 seconds ago

Copy the code

The command to review


## List Docker CLI commands
docker
docker container --help

## Display Docker version and info
docker --version
docker version
docker info

## Execute Docker image
docker run hello-world

## List Docker images
docker image ls

## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq

Copy the code

conclusion

With Docker, the process of extending your application is to start a new executable instead of running a heavy VM host.