mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add basics for controlling a container's lifecycle
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
This commit is contained in:
parent
349adf4d4d
commit
6dc2f55136
1 changed files with 29 additions and 3 deletions
|
@ -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
|
||||
------------------------------
|
||||
|
|
Loading…
Reference in a new issue