1.6-docker Container Management

Source: Internet
Author: User
Tags custom name docker ps

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

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.