start container docker run-ti Ubuntu/bin/bash
Docker run = First Docker Create and then Docker start
-T means to have Docker assign a pseudo terminal and bind to the container's standard input
When the-T is used, the command operation can be performed, but only one time, and then the input is closed.
Such as:
-I means keep the container's standard input open, allowing you to enter commands continuously
Such as:
Can obviously feel the difference between the two ...
Ubuntu is the image of the noun, Ubuntu can also be replaced by the image ID
/bin/bash is the specified application that needs to be executed.
This command can be used without filling, and the container will be started according to the image preset.
The container automatically stops if the command finishes executing, or if the specified application is terminated.
/bin/bash This command is definitely the end of an execution, then the corresponding container will also stop. If you start a Tomcat, the container will not stop automatically if Tomcat is not turned off.
Because this is the launch of a bash terminal, so the-ti command only works, this time with the two parameters to allow the user to continue to interact, but after the interaction, you exit, the container will also terminate.
The user can exit the container using exit or Ctrl+d, at which point the exiting container is terminated.
If you use other commands, such as Echo Aaa,docker, the container will be terminated immediately after execution.
At this time Docker Run-ti Ubuntu Echo AAA with Docker run Ubuntu Echo AAA is an effect that is all started after the command is finished and immediately stops the container.
-d means that this container runs in a daemon state and returns a container ID when it is started.
I used to think that this thing means that when you start, the specified run program ends, and the container does not end.
But in fact, this is not the case ... The specified program has ended ... The container will also end ...
A mirror running in a daemon will only return the ID of a container to you and will not print Docker logs.
Containers started with-D return a container ID
You can use the Docker PS command to see if you started successfully in a daemon state.
View Container Docker PS with Docker ps-a
You can use Docker PS to view all the containers that are started
You can use Docker ps-a to view all the containers that have been created, including those that are started and not started.
terminate container docker stop xxx
XXX can be a names in Docker PS or it can be an ID
Create a container docker create
The Docker create usage is the same as the Docker run, and the Docker run is actually calling Docker start on the basis of the Docker create preset.
Note that Docker create does not have a-D and has no daemon status.
start container docker start xxx
XXX can be a names in Docker PS or it can be an ID
The user can exit the container using exit or Ctrl+d, at which point the exiting container is terminated.
Enter container Docker exec-ti Mad_davinci/bin/bash
EXEC is the command to enter the container-t means that Docker is assigned a pseudo terminal and bound to the standard input of the container on-I means that the container's standard input remains open, you can continuously enter the command-d-d to indicate that the container is running in a daemon state. Mad_davinci is the container name, which can be either a container name or a container ID. /bin/bash the procedure to be executed after entering the container
Remove container docker rm xxx
XXX can be either a container name or a container ID, and XXX can be multiple containers, separated by a space.