From 6dc2f5513648c42b2e71e55c4a4ea6cd3073ce55 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Tue, 18 Feb 2014 21:45:48 -0500 Subject: [PATCH] Add basics for controlling a container's lifecycle Docker-DCO-1.1-Signed-off-by: Brian Goff (github: cpuguy83) --- docs/sources/use/basics.rst | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/sources/use/basics.rst b/docs/sources/use/basics.rst index 75907efa39..24c22bba39 100644 --- a/docs/sources/use/basics.rst +++ b/docs/sources/use/basics.rst @@ -122,12 +122,38 @@ Starting a long-running worker process sudo docker kill $JOB -Listing all running containers ------------------------------- +Listing containers +------------------ .. code-block:: bash - sudo docker ps + sudo docker ps # Lists only running containers + sudo docker ps -a # Lists all containers + + +Controlling containers +---------------------- +.. code-block:: bash + + # Start a new container + JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done") + + # Stop the container + docker stop $JOB + + # Start the container + docker start $JOB + + # Restart the container + docker restart $JOB + + # SIGKILL a container + docker kill $JOB + + # Remove a container + docker stop $JOB # Container must be stopped to remove it + docker rm $JOB + Bind a service on a TCP port ------------------------------