Docker minimalist Guide

Time:2020-11-27

What is docker?

Beginners can use the concept of “virtual machine” to understand docker. When we want to build a virtual machine, we need to download two things: virtual machine software (such as VMware) and. ISO file (such as Ubuntu), and then we can use the Ubuntu system in VMware. Similarly, when we want to build a running environment for a program, docker comes in handy. Docker encapsulates the running environment of the program inimage(analogy for Ubuntu)container(similar to VMware) to use these images. As a matter of fact, docker is much more efficient than virtual machine. Readers can refer to some information by themselves.


1. AccessimageFour approaches to

  • Pull from image warehouse:

    Docker pull image name: image version
  • Compile from dockerfile. Image name is a new image name specified by itself, the same below.

    Docker build - t image name dockerfile file path
  • Load from tar file:

    Docker load file name.tar
  • Extract from the container. The container ID can be accessed bydocker ps -aAnd so on. Note: just enter the first few digits of the container number.

    Docker commit container number image name

2. List the existing images

docker images

3. Save the existing image

  • Save as a. Tar file

    Docker save image name > file name.tar

4. Construct the container and run the image

  • Run in the background without blocking the current window

    Docker run - D image name: image version

    Other commonly used parameters are: – P mapping port, – V mapping path, for example:

    Docker run - P 80:81 image name: image version

5. List containers

  • Only running containers are listed

    docker ps
  • List all containers

    docker ps -a

6. Enter the container

  • Enter the container through bash

    Container - basec exit docker No

7. Exit the container

exit

8. Restart the container

Docker start container number

9. Delete container

Docker RM - f container number

Finally, a novice docker video is recommended
[https://www.bilibili.com/video/BV1R4411F7t9?from=search&seid=8820304276251717116]