Docker Container Management
* Docker create-it CentOS//This can create a container, but the container does not start
* Docker start container_id//Start container, you can use Docker PS to see, there is a start stop, and restart
Previously we used a Docker run equivalent to create and start
* Docker run-i-t CentOS Bash
This enters a virtual terminal, we can run some commands, exit the Bash with command exit or CTRL d, and the container will stop when it exits. If you start the container with start and exit, the container does not stop, and exit does not stop when the exec goes in. This is the difference between run and start.
* Docker run-d allows containers to run in the background
For example: Docker run-d CentOS bash-c "while:; Do echo "123"; Sleep 1; Done "
* Docker run--name web-itd CentOS Bash//--name give container a custom name
* Docker run--rm-it CentOS bash-c "Sleep"//--rm can be removed after the container exits, where the command finishes executing the container exits and cannot be used with-D
* Docker logs can get the running history output information of the container, using the following
Docker logs container_id
* Docker attach can enter a container running in the background, such as
Docker attach container_id//But the attach command is not very useful, for example, we want to exit the terminal, we have to exit, so the container will also exit, there is a way
Docker exec-i-T container_id Bash//can temporarily open a virtual terminal, and after exit, the container is still running
* Docker RM container_id//container_id is PS when checked see, so you can put all container deleted, if it is run container, can add-f
* Docker export container_id > File.tar//Export container, can be migrated to other machines, need to import
Cat File.tar |docker import-wyp_test//This will generate a wyp_test image, on the basis of mirroring, generate a container, the container and the exported container, in addition to the name and ID, the content is the same.
1.6-docker Container Management