|
@@ -41,7 +41,7 @@ To stop a container, use ``docker stop``
|
|
To kill the container, use ``docker kill``
|
|
To kill the container, use ``docker kill``
|
|
|
|
|
|
.. _cli_attach_examples:
|
|
.. _cli_attach_examples:
|
|
-
|
|
|
|
|
|
+
|
|
Examples:
|
|
Examples:
|
|
~~~~~~~~~
|
|
~~~~~~~~~
|
|
|
|
|
|
@@ -55,8 +55,8 @@ Examples:
|
|
Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
|
|
Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
|
|
Swap: 786428k total, 0k used, 786428k free, 221740k cached
|
|
Swap: 786428k total, 0k used, 786428k free, 221740k cached
|
|
|
|
|
|
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
|
|
|
- 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
|
|
|
|
|
|
+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
|
|
|
+ 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
|
|
|
|
|
|
top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
|
top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
|
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
|
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
|
@@ -64,8 +64,8 @@ Examples:
|
|
Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
|
|
Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
|
|
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
|
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
|
|
|
|
|
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
|
|
|
- 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
|
|
|
|
|
+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
|
|
|
+ 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
|
|
|
|
|
|
|
|
|
top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
|
|
top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
|
|
@@ -74,9 +74,9 @@ Examples:
|
|
Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
|
|
Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
|
|
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
|
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
|
|
|
|
|
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
|
|
|
- 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
|
|
|
- ^C$
|
|
|
|
|
|
+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
|
|
|
+ 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
|
|
|
+ ^C$
|
|
$ sudo docker stop $ID
|
|
$ sudo docker stop $ID
|
|
|
|
|
|
.. _cli_build:
|
|
.. _cli_build:
|
|
@@ -157,7 +157,7 @@ by using the ``git://`` schema.
|
|
|
|
|
|
-m="": Commit message
|
|
-m="": Commit message
|
|
-author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
|
|
-author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
|
|
- -run="": Configuration to be applied when the image is launched with `docker run`.
|
|
|
|
|
|
+ -run="": Configuration to be applied when the image is launched with `docker run`.
|
|
(ex: '{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
|
|
(ex: '{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
|
|
|
|
|
|
Full -run example (multiline is ok within a single quote ``'``)
|
|
Full -run example (multiline is ok within a single quote ``'``)
|
|
@@ -239,7 +239,7 @@ Shell 1: Listening for events
|
|
.............................
|
|
.............................
|
|
|
|
|
|
.. code-block:: bash
|
|
.. code-block:: bash
|
|
-
|
|
|
|
|
|
+
|
|
$ sudo docker events
|
|
$ sudo docker events
|
|
|
|
|
|
Shell 2: Start and Stop a Container
|
|
Shell 2: Start and Stop a Container
|
|
@@ -405,7 +405,7 @@ Insert file from github
|
|
Usage: docker kill CONTAINER [CONTAINER...]
|
|
Usage: docker kill CONTAINER [CONTAINER...]
|
|
|
|
|
|
Kill a running container (Send SIGKILL)
|
|
Kill a running container (Send SIGKILL)
|
|
-
|
|
|
|
|
|
+
|
|
The main process inside the container will be sent SIGKILL.
|
|
The main process inside the container will be sent SIGKILL.
|
|
|
|
|
|
.. _cli_login:
|
|
.. _cli_login:
|
|
@@ -515,7 +515,7 @@ The main process inside the container will be sent SIGKILL.
|
|
|
|
|
|
Remove one or more containers
|
|
Remove one or more containers
|
|
-link="": Remove the link instead of the actual container
|
|
-link="": Remove the link instead of the actual container
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
Examples:
|
|
Examples:
|
|
~~~~~~~~~
|
|
~~~~~~~~~
|
|
@@ -620,58 +620,51 @@ use-cases, like running Docker within Docker.
|
|
|
|
|
|
docker run -w /path/to/dir/ -i -t ubuntu pwd
|
|
docker run -w /path/to/dir/ -i -t ubuntu pwd
|
|
|
|
|
|
-The ``-w`` lets the command being executed inside directory given,
|
|
|
|
-here /path/to/dir/. If the path does not exists it is created inside the
|
|
|
|
|
|
+The ``-w`` lets the command being executed inside directory given,
|
|
|
|
+here /path/to/dir/. If the path does not exists it is created inside the
|
|
container.
|
|
container.
|
|
|
|
|
|
.. code-block:: bash
|
|
.. code-block:: bash
|
|
|
|
|
|
docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
|
|
docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
|
|
|
|
|
|
-The ``-v`` flag mounts the current working directory into the container.
|
|
|
|
-The ``-w`` lets the command being executed inside the current
|
|
|
|
|
|
+The ``-v`` flag mounts the current working directory into the container.
|
|
|
|
+The ``-w`` lets the command being executed inside the current
|
|
working directory, by changing into the directory to the value
|
|
working directory, by changing into the directory to the value
|
|
returned by ``pwd``. So this combination executes the command
|
|
returned by ``pwd``. So this combination executes the command
|
|
using the container, but inside the current working directory.
|
|
using the container, but inside the current working directory.
|
|
|
|
|
|
.. code-block:: bash
|
|
.. code-block:: bash
|
|
|
|
|
|
- docker run -p 127.0.0.0::80 ubuntu bash
|
|
|
|
-
|
|
|
|
-The ``-p`` flag now allows you to bind a port to a specific
|
|
|
|
-interface of the host machine. In this example port ``80`` of the
|
|
|
|
-container will have a dynamically allocated port bound to 127.0.0.1
|
|
|
|
-of the host.
|
|
|
|
-
|
|
|
|
-.. code-block:: bash
|
|
|
|
-
|
|
|
|
- docker run -p 127.0.0.1:80:80 ubuntu bash
|
|
|
|
|
|
+ docker run -p 127.0.0.0:80:8080 ubuntu bash
|
|
|
|
|
|
-This will bind port ``80`` of the container to port ``80`` on 127.0.0.1 of your
|
|
|
|
-host machine.
|
|
|
|
|
|
+This binds port ``8080`` of the container to port ``80`` on 127.0.0.1 of the
|
|
|
|
+host machine. :ref:`port_redirection` explains in detail how to manipulate ports
|
|
|
|
+in Docker.
|
|
|
|
|
|
.. code-block:: bash
|
|
.. code-block:: bash
|
|
|
|
|
|
docker run -expose 80 ubuntu bash
|
|
docker run -expose 80 ubuntu bash
|
|
|
|
|
|
-This will expose port ``80`` of the container for use within a link
|
|
|
|
-without publishing the port to the host system's interfaces.
|
|
|
|
|
|
+This exposes port ``80`` of the container for use within a link without
|
|
|
|
+publishing the port to the host system's interfaces. :ref:`port_redirection`
|
|
|
|
+explains in detail how to manipulate ports in Docker.
|
|
|
|
|
|
.. code-block:: bash
|
|
.. code-block:: bash
|
|
|
|
|
|
docker run -name console -t -i ubuntu bash
|
|
docker run -name console -t -i ubuntu bash
|
|
|
|
|
|
-This will create and run a new container with the container name
|
|
|
|
|
|
+This will create and run a new container with the container name
|
|
being ``console``.
|
|
being ``console``.
|
|
|
|
|
|
.. code-block:: bash
|
|
.. code-block:: bash
|
|
|
|
|
|
docker run -link /redis:redis -name console ubuntu bash
|
|
docker run -link /redis:redis -name console ubuntu bash
|
|
|
|
|
|
-The ``-link`` flag will link the container named ``/redis`` into the
|
|
|
|
|
|
+The ``-link`` flag will link the container named ``/redis`` into the
|
|
newly created container with the alias ``redis``. The new container
|
|
newly created container with the alias ``redis``. The new container
|
|
can access the network and environment of the redis container via
|
|
can access the network and environment of the redis container via
|
|
-environment variables. The ``-name`` flag will assign the name ``console``
|
|
|
|
|
|
+environment variables. The ``-name`` flag will assign the name ``console``
|
|
to the newly created container.
|
|
to the newly created container.
|
|
|
|
|
|
.. _cli_search:
|
|
.. _cli_search:
|
|
@@ -712,7 +705,7 @@ to the newly created container.
|
|
Stop a running container (Send SIGTERM, and then SIGKILL after grace period)
|
|
Stop a running container (Send SIGTERM, and then SIGKILL after grace period)
|
|
|
|
|
|
-t=10: Number of seconds to wait for the container to stop before killing it.
|
|
-t=10: Number of seconds to wait for the container to stop before killing it.
|
|
-
|
|
|
|
|
|
+
|
|
The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL
|
|
The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL
|
|
|
|
|
|
.. _cli_tag:
|
|
.. _cli_tag:
|
|
@@ -757,6 +750,3 @@ Show the version of the docker client, daemon, and latest released version.
|
|
Usage: docker wait [OPTIONS] NAME
|
|
Usage: docker wait [OPTIONS] NAME
|
|
|
|
|
|
Block until a container stops, then print its exit code.
|
|
Block until a container stops, then print its exit code.
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|