Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you! Container (15)

Image, “Image,” is the same concept as the ISO Image you install on your operating system. Container is the operating system that starts from this image. A single image can be used to launch any number of containers in any number of places, which means that a single image can host many operating systems. Of course, the mirror, not necessarily the operating system mirror, but also the software mirror. When you understand, you’ll see that my explanation is not entirely correct. But, you can understand it this way. Github source: github.com/limingios/d…

What is the Container

  • Created by Image
  • Create a Container Layer on top of the Image Layer (read-write)
  • Analogy object-oriented, class and instance, container is instance, Image is class
  • The Image stores and distributes the application, and the Container runs the app



The operation of the Container

So let’s get the Image ready

cd ./labs/helloworld
sudo docker build -t liming/hello-world:latest .
Copy the code






  • create
sudo docker image ls
sudo docker container ls
sudo docker run liming/hello-world
sudo docker container ls
 sudo docker container ls -a
Copy the code









Sudo Docker container ls is empty every time after running sudo Docker container ls, there is no list in the container. Because there is no program running in the background, it will not reside in memory, so the status = exited exits.

sudo docker run -it liming/hello-world
Copy the code



The it command is added to enable the backend to run directly into the container, and the newly created state is changed to up and exited. Through ls, you can see the file format similar to a Linux system.




  • The list of
sudo docker container ls
Copy the code
  • delete
Sudo docker RM container IDCopy the code

Docker command distribution

  • Management Commands
  • Commands (run Commands for coordination management)






Technique Delete containers in batches

# delete only those that exit
docker rm  $(docker container ls -f "status=exited" -q)
# delete all
docker rm  $(docker container ls -aq)
Copy the code



The command set




PS: Want to play Docker familiar with the command is the first, this thing is more practice more practice, slowly easy!