Docker Learning Notes (iv) Container view start stop Delete __docker

Source: Internet
Author: User
Tags docker stop container docker ps
View

Docker PS
There are some main parameters to say
1. Without parameters, to view the currently running container
2. A, view all containers including the stop state of the container
3-L to view the newly created container
4.-n=x, view the last created X container
Make a list of the results of Docker PS
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
What do these separate represent?
CONTAINER ID: Container ID, unique identity container
Image: Mirror used when creating a container
Command: Commands that run at the end of the container
CREATED: Time the container was created
Status: The state of the container (you will see the upxxx, indicating the running state)
PORTS: The port slogan of opening to the outside
NAMES: Container name (also unique, Docker is not allowed to create containers with the same container name)

Start

When we use Docker ps-a we see that some of the container states are created, and here we need to start the container with the Docker start container name or the container ID. However, it should be noted that, with this command, the container enters the running state, and when the container completes its task, it exits itself and enters the stop state. If you need to start the start command again
Here is a parameter that allows the container to automatically restart after exiting
--restart This parameter checks the exit code of the container and accordingly determines whether the container should be restarted.

This example should not be easy to try, this will keep the output of Hello World, with CTRL + C did not stop this (after here to think about why did not stop ...) )
Finally, I opened another terminal and typed it in.
Docker stop Docker_restart terminated the container

Also said in the above command is
Docker stop container name or container ID
And this docker Stop command sends a sigterm signal (can be captured) to the container process, and the default behavior is that the container exits.
If you want to force a container to stop, it's best to use the Docker kill command
It is to send a sigkill signal (not to be captured) to delete

We can not delete a running container, we must first Docker stop or Docker kill before we can remove
Command: Docker RM container Name
of course, if we add the-f parameter We can also delete a running container
How to delete all containers at once Docker did not give the relevant command, but we can do so

-Q is a list of container IDs only

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.