diff options
author | unclejack <unclejacksons@gmail.com> | 2014-04-02 16:00:12 +0300 |
---|---|---|
committer | unclejack <unclejacksons@gmail.com> | 2014-04-02 16:23:01 +0300 |
commit | 63c7941172376e81c5e17206f39d7c78c0e95b69 (patch) | |
tree | 5ca277a3eaea3c557bc61c217365523ba960c474 /docs/sources | |
parent | 506055d973ec3a393fa5f8438b41b2318e95b21c (diff) | |
download | docker-63c7941172376e81c5e17206f39d7c78c0e95b69.tar.gz |
docs: explain what docker run -a does
This adds a bit of documentation for the `-a` flag for docker run.
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Diffstat (limited to 'docs/sources')
-rw-r--r-- | docs/sources/reference/commandline/cli.rst | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/sources/reference/commandline/cli.rst b/docs/sources/reference/commandline/cli.rst index 324b84b0ae..64dff1e1c2 100644 --- a/docs/sources/reference/commandline/cli.rst +++ b/docs/sources/reference/commandline/cli.rst @@ -1359,6 +1359,35 @@ ID may be optionally suffixed with ``:ro`` or ``:rw`` to mount the volumes in read-only or read-write mode, respectively. By default, the volumes are mounted in the same mode (read write or read only) as the reference container. +The ``-a`` flag tells ``docker run`` to bind to the container's stdin, stdout +or stderr. This makes it possible to manipulate the output and input as needed. + +.. code-block:: bash + + $ sudo echo "test" | docker run -i -a stdin ubuntu cat - + +This pipes data into a container and prints the container's ID by attaching +only to the container's stdin. + +.. code-block:: bash + + $ sudo docker run -a stderr ubuntu echo test + +This isn't going to print anything unless there's an error because we've only +attached to the stderr of the container. The container's logs still store +what's been written to stderr and stdout. + +.. code-block:: bash + + $ sudo cat somefile | docker run -i -a stdin mybuilder dobuild + +This is how piping a file into a container could be done for a build. +The container's ID will be printed after the build is done and the build logs +could be retrieved using ``docker logs``. This is useful if you need to pipe +a file or something else into a container and retrieve the container's ID once +the container has finished running. + + A complete example .................. |