update commands.go

update docker.go

move to pkg

update docs

update name and copyright

change --sinceId to --since-id, update completion and docs

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor@docker.com> (github: vieux)
This commit is contained in:
Victor Vieux 2013-12-23 11:43:54 -08:00 committed by Tibor Vass
parent 98b39c91de
commit 33415ebe36
3 changed files with 117 additions and 116 deletions

View File

@ -25,7 +25,7 @@ __docker_containers_all()
{ {
local containers local containers
containers="$( docker ps -a -q )" containers="$( docker ps -a -q )"
names="$( docker inspect -format '{{.Name}}' $containers | sed 's,^/,,' )" names="$( docker inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
} }
@ -33,7 +33,7 @@ __docker_containers_running()
{ {
local containers local containers
containers="$( docker ps -q )" containers="$( docker ps -q )"
names="$( docker inspect -format '{{.Name}}' $containers | sed 's,^/,,' )" names="$( docker inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
} }
@ -41,7 +41,7 @@ __docker_containers_stopped()
{ {
local containers local containers
containers="$( comm -13 <(docker ps -q | sort -u) <(docker ps -a -q | sort -u) )" containers="$( comm -13 <(docker ps -q | sort -u) <(docker ps -a -q | sort -u) )"
names="$( docker inspect -format '{{.Name}}' $containers | sed 's,^/,,' )" names="$( docker inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$names $containers" -- "$cur" ) )
} }
@ -73,7 +73,7 @@ __docker_containers_and_images()
{ {
local containers images local containers images
containers="$( docker ps -a -q )" containers="$( docker ps -a -q )"
names="$( docker inspect -format '{{.Name}}' $containers | sed 's,^/,,' )" names="$( docker inspect --format '{{.Name}}' $containers | sed 's,^/,,' )"
images="$( docker images | awk 'NR>1{print $1":"$2}' )" images="$( docker images | awk 'NR>1{print $1":"$2}' )"
COMPREPLY=( $( compgen -W "$images $names $containers" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$images $names $containers" -- "$cur" ) )
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
@ -118,7 +118,7 @@ _docker_build()
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "-no-cache -t -q -rm" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--no-cache -t -q --rm" -- "$cur" ) )
;; ;;
*) *)
_filedir _filedir
@ -138,7 +138,7 @@ _docker_commit()
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "-author -m -run" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--author -m --run" -- "$cur" ) )
;; ;;
*) *)
local counter=$cpos local counter=$cpos
@ -191,7 +191,7 @@ _docker_events()
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "-since" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--since" -- "$cur" ) )
;; ;;
*) *)
;; ;;
@ -223,7 +223,7 @@ _docker_images()
{ {
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "-a -notrunc -q -viz" -- "$cur" ) ) COMPREPLY=( $( compgen -W "-a --no-trunc -q --viz" -- "$cur" ) )
;; ;;
*) *)
local counter=$cpos local counter=$cpos
@ -308,7 +308,7 @@ _docker_port()
_docker_ps() _docker_ps()
{ {
case "$prev" in case "$prev" in
-beforeId|-n|-sinceId) -before-id|-n|-since-id)
return return
;; ;;
*) *)
@ -317,7 +317,7 @@ _docker_ps()
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "-a -beforeId -l -n -notrunc -q -s -sinceId" -- "$cur" ) ) COMPREPLY=( $( compgen -W "-a --before-id -l -n --no-trunc -q -s --since-id" -- "$cur" ) )
;; ;;
*) *)
;; ;;
@ -388,13 +388,13 @@ _docker_rmi()
_docker_run() _docker_run()
{ {
case "$prev" in case "$prev" in
-cidfile) --cidfile)
_filedir _filedir
;; ;;
-volumes-from) --volumes-from)
__docker_containers_all __docker_containers_all
;; ;;
-a|-c|-dns|-e|-entrypoint|-h|-lxc-conf|-m|-p|-u|-v|-w) -a|-c|--dns|-e|--entrypoint|-h|--lxc-conf|-m|-p|-u|-v|-w)
return return
;; ;;
*) *)
@ -403,13 +403,13 @@ _docker_run()
case "$cur" in case "$cur" in
-*) -*)
COMPREPLY=( $( compgen -W "-a -c -cidfile -d -dns -e -entrypoint -h -i -lxc-conf -m -n -p -privileged -t -u -v -volumes-from -w" -- "$cur" ) ) COMPREPLY=( $( compgen -W "-a -c --cidfile -d --dns -e --entrypoint -h -i --lxc-conf -m -n -p --privileged -t -u -v --volumes-from -w" -- "$cur" ) )
;; ;;
*) *)
local counter=$cpos local counter=$cpos
while [ $counter -le $cword ]; do while [ $counter -le $cword ]; do
case "${words[$counter]}" in case "${words[$counter]}" in
-a|-c|-cidfile|-dns|-e|-entrypoint|-h|-lxc-conf|-m|-p|-u|-v|-volumes-from|-w) -a|-c|--cidfile|--dns|-e|--entrypoint|-h|--lxc-conf|-m|-p|-u|-v|--volumes-from|-w)
(( counter++ )) (( counter++ ))
;; ;;
-*) -*)
@ -430,7 +430,7 @@ _docker_run()
_docker_search() _docker_search()
{ {
COMPREPLY=( $( compgen -W "-notrunc" "-stars" "-trusted" -- "$cur" ) ) COMPREPLY=( $( compgen -W "--no-trunc" "--stars" "--trusted" -- "$cur" ) )
} }
_docker_start() _docker_start()

View File

@ -174,7 +174,7 @@ __docker_subcommand () {
(ps) (ps)
_arguments '-a[Show all containers. Only running containers are shown by default]' \ _arguments '-a[Show all containers. Only running containers are shown by default]' \
'-h[Show help]' \ '-h[Show help]' \
'-beforeId=-[Show only container created before Id, include non-running one]:containers:__docker_containers' \ '-before-id=-[Show only container created before Id, include non-running one]:containers:__docker_containers' \
'-n=-[Show n last created containers, include non-running one]:n:(1 5 10 25 50)' '-n=-[Show n last created containers, include non-running one]:n:(1 5 10 25 50)'
;; ;;
(tag) (tag)
@ -189,9 +189,9 @@ __docker_subcommand () {
'-a=-[Attach to stdin, stdout or stderr]:toggle:(true false)' \ '-a=-[Attach to stdin, stdout or stderr]:toggle:(true false)' \
'-c=-[CPU shares (relative weight)]:CPU shares: ' \ '-c=-[CPU shares (relative weight)]:CPU shares: ' \
'-d[Detached mode: leave the container running in the background]' \ '-d[Detached mode: leave the container running in the background]' \
'*-dns=[Set custom dns servers]:dns server: ' \ '*--dns=[Set custom dns servers]:dns server: ' \
'*-e=[Set environment variables]:environment variable: ' \ '*-e=[Set environment variables]:environment variable: ' \
'-entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \ '--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \
'-h=-[Container host name]:hostname:_hosts' \ '-h=-[Container host name]:hostname:_hosts' \
'-i[Keep stdin open even if not attached]' \ '-i[Keep stdin open even if not attached]' \
'-m=-[Memory limit (in bytes)]:limit: ' \ '-m=-[Memory limit (in bytes)]:limit: ' \
@ -199,7 +199,7 @@ __docker_subcommand () {
'-t=-[Allocate a pseudo-tty]:toggle:(true false)' \ '-t=-[Allocate a pseudo-tty]:toggle:(true false)' \
'-u=-[Username or UID]:user:_users' \ '-u=-[Username or UID]:user:_users' \
'*-v=-[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\ '*-v=-[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\
'-volumes-from=-[Mount volumes from the specified container]:volume: ' \ '--volumes-from=-[Mount volumes from the specified container]:volume: ' \
'(-):images:__docker_images' \ '(-):images:__docker_images' \
'(-):command: _command_names -e' \ '(-):command: _command_names -e' \
'*::arguments: _normal' '*::arguments: _normal'

View File

@ -26,22 +26,21 @@ To list available commands, either run ``docker`` with no parameters or execute
:: ::
Usage of docker: Usage of docker:
-D=false: Enable debug mode -D, --debug=false: Enable debug mode
-H=[unix:///var/run/docker.sock]: tcp://[host[:port]] to bind or unix://[/path/to/socket] to use. When host=[0.0.0.0], port=[4243] or path=[/var/run/docker.sock] is omitted, default values are used. -H, --host=[]: Multiple tcp://host:port or unix://path/to/socket to bind in daemon mode, single connection otherwise
-api-enable-cors=false: Enable CORS headers in the remote API --api-enable-cors=false: Enable CORS headers in the remote API
-b="": Attach containers to a pre-existing network bridge; use 'none' to disable container networking -b, --bridge="": Attach containers to a pre-existing network bridge; use 'none' to disable container networking
-bip="": Use the provided CIDR notation address for the dynamically created bridge (docker0); Mutually exclusive of -b --bip="": Use this CIDR notation address for the network bridge's IP, not compatible with -b
-d=false: Enable daemon mode -d, --daemon=false: Enable daemon mode
-dns="": Force docker to use specific DNS servers --dns=[]: Force docker to use specific DNS servers
-g="/var/lib/docker": Path to use as the root of the docker runtime -g, --graph="/var/lib/docker": Path to use as the root of the docker runtime
-icc=true: Enable inter-container communication --icc=true: Enable inter-container communication
-ip="0.0.0.0": Default IP address to use when binding container ports --ip="0.0.0.0": Default IP address to use when binding container ports
-iptables=true: Disable docker's addition of iptables rules --iptables=true: Disable docker's addition of iptables rules
-mtu=1500: Set the containers network mtu -p, --pidfile="/var/run/docker.pid": Path to use for daemon PID file
-p="/var/run/docker.pid": Path to use for daemon PID file -r, --restart=true: Restart previously running containers
-r=true: Restart previously running containers -s, --storage-driver="": Force the docker runtime to use a specific storage driver
-s="": Force the docker runtime to use a specific storage driver -v, --version=false: Print version information and quit
-v=false: Print version information and quit
The Docker daemon is the persistent process that manages containers. Docker uses the same binary for both the The Docker daemon is the persistent process that manages containers. Docker uses the same binary for both the
daemon and client. To run the daemon you provide the ``-d`` flag. daemon and client. To run the daemon you provide the ``-d`` flag.
@ -75,8 +74,8 @@ the ``-H`` flag for the client.
Attach to a running container. Attach to a running container.
-nostdin=false: Do not attach stdin --no-stdin=false: Do not attach stdin
-sig-proxy=true: Proxify all received signal to the process (even in non-tty mode) --sig-proxy=true: Proxify all received signal to the process (even in non-tty mode)
You can detach from the container again (and leave it running) with You can detach from the container again (and leave it running) with
``CTRL-c`` (for a quiet exit) or ``CTRL-\`` to get a stacktrace of ``CTRL-c`` (for a quiet exit) or ``CTRL-\`` to get a stacktrace of
@ -135,11 +134,11 @@ Examples:
Usage: docker build [OPTIONS] PATH | URL | - Usage: docker build [OPTIONS] PATH | URL | -
Build a new container image from the source code at PATH Build a new container image from the source code at PATH
-t="": Repository name (and optionally a tag) to be applied -t, --time="": Repository name (and optionally a tag) to be applied
to the resulting image in case of success. to the resulting image in case of success.
-q=false: Suppress verbose build output. -q, --quiet=false: Suppress verbose build output.
-no-cache: Do not use the cache when building the image. --no-cache: Do not use the cache when building the image.
-rm: Remove intermediate containers after a successful build --rm: Remove intermediate containers after a successful build
The files at ``PATH`` or ``URL`` are called the "context" of the build. The The files at ``PATH`` or ``URL`` are called the "context" of the build. The
build process may refer to any of the files in the context, for example when build process may refer to any of the files in the context, for example when
@ -233,9 +232,9 @@ by using the ``git://`` schema.
Create a new image from a container's changes Create a new image from a container's changes
-m="": Commit message -m, --message="": Commit message
-author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>" -a, --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: -run='{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}') (ex: -run='{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
.. _cli_commit_examples: .. _cli_commit_examples:
@ -279,7 +278,7 @@ run ``ls /etc``.
Full -run example Full -run example
................. .................
The ``-run`` JSON hash changes the ``Config`` section when running ``docker inspect CONTAINERID`` The ``--run`` JSON hash changes the ``Config`` section when running ``docker inspect CONTAINERID``
or ``config`` when running ``docker inspect IMAGEID``. or ``config`` when running ``docker inspect IMAGEID``.
(Multiline is okay within a single quote ``'``) (Multiline is okay within a single quote ``'``)
@ -379,7 +378,7 @@ For example:
Get real time events from the server Get real time events from the server
-since="": Show previously created events and then stream. --since="": Show previously created events and then stream.
(either seconds since epoch, or date string as below) (either seconds since epoch, or date string as below)
.. _cli_events_example: .. _cli_events_example:
@ -459,8 +458,8 @@ For example:
Show the history of an image Show the history of an image
-notrunc=false: Don't truncate output --no-trunc=false: Don't truncate output
-q=false: only show numeric IDs -q, --quiet=false: only show numeric IDs
To see how the ``docker:latest`` image was built: To see how the ``docker:latest`` image was built:
@ -507,11 +506,11 @@ To see how the ``docker:latest`` image was built:
List images List images
-a=false: show all images (by default filter out the intermediate images used to build) -a, --all=false: show all images (by default filter out the intermediate images used to build)
-notrunc=false: Don't truncate output --no-trunc=false: Don't truncate output
-q=false: only show numeric IDs -q, --quiet=false: only show numeric IDs
-tree=false: output graph in tree format --tree=false: output graph in tree format
-viz=false: output graph in graphviz format --viz=false: output graph in graphviz format
Listing the most recently created images Listing the most recently created images
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -535,7 +534,7 @@ Listing the full length image IDs
.. code-block:: bash .. code-block:: bash
$ sudo docker images -notrunc | head $ sudo docker images --no-trunc | head
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB
committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB
@ -552,7 +551,7 @@ Displaying images visually
.. code-block:: bash .. code-block:: bash
$ sudo docker images -viz | dot -Tpng -o docker.png $ sudo docker images --viz | dot -Tpng -o docker.png
.. image:: docker_images.gif .. image:: docker_images.gif
:alt: Example inheritance graph of Docker images. :alt: Example inheritance graph of Docker images.
@ -563,7 +562,7 @@ Displaying image hierarchy
.. code-block:: bash .. code-block:: bash
$ sudo docker images -tree $ sudo docker images --tree
├─8dbd9e392a96 Size: 131.5 MB (virtual 131.5 MB) Tags: ubuntu:12.04,ubuntu:latest,ubuntu:precise ├─8dbd9e392a96 Size: 131.5 MB (virtual 131.5 MB) Tags: ubuntu:12.04,ubuntu:latest,ubuntu:precise
└─27cf78414709 Size: 180.1 MB (virtual 180.1 MB) └─27cf78414709 Size: 180.1 MB (virtual 180.1 MB)
@ -702,7 +701,7 @@ Insert file from GitHub
Return low-level information on a container/image Return low-level information on a container/image
-format="": Format the output using the given go template. -f, --format="": Format the output using the given go template.
By default, this will render all results in a JSON array. If a format By default, this will render all results in a JSON array. If a format
is specified, the given template will be executed for each result. is specified, the given template will be executed for each result.
@ -721,7 +720,7 @@ fairly straightforward manner.
.. code-block:: bash .. code-block:: bash
$ sudo docker inspect -format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID $ sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
List All Port Bindings List All Port Bindings
...................... ......................
@ -790,9 +789,9 @@ Known Issues (kill)
Register or Login to the docker registry server Register or Login to the docker registry server
-e="": email -e, --email="": email
-p="": password -p, --password="": password
-u="": username -u, --username="": username
If you want to login to a private registry you can If you want to login to a private registry you can
specify this by adding the server name. specify this by adding the server name.
@ -812,12 +811,14 @@ Known Issues (kill)
Fetch the logs of a container Fetch the logs of a container
-f, --follow=false: Follow log output
The ``docker logs`` command is a convenience which batch-retrieves whatever The ``docker logs`` command is a convenience which batch-retrieves whatever
logs are present at the time of execution. This does not guarantee execution logs are present at the time of execution. This does not guarantee execution
order when combined with a ``docker run`` (i.e. your run may not have generated order when combined with a ``docker run`` (i.e. your run may not have generated
any logs at the time you execute ``docker logs``). any logs at the time you execute ``docker logs``).
The ``docker logs -f`` command combines ``docker logs`` and ``docker attach``: The ``docker logs --follow`` command combines ``docker logs`` and ``docker attach``:
it will first return all logs from the beginning and then continue streaming it will first return all logs from the beginning and then continue streaming
new output from the container's stdout and stderr. new output from the container's stdout and stderr.
@ -845,9 +846,9 @@ new output from the container's stdout and stderr.
List containers List containers
-a=false: Show all containers. Only running containers are shown by default. -a, --all=false: Show all containers. Only running containers are shown by default.
-notrunc=false: Don't truncate output --no-trunc=false: Don't truncate output
-q=false: Only display numeric IDs -q, --quiet=false: Only display numeric IDs
Running ``docker ps`` showing 2 linked containers. Running ``docker ps`` showing 2 linked containers.
@ -903,7 +904,7 @@ Running ``docker ps`` showing 2 linked containers.
Usage: docker rm [OPTIONS] CONTAINER Usage: docker rm [OPTIONS] CONTAINER
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
Known Issues (rm) Known Issues (rm)
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
@ -926,7 +927,7 @@ This will remove the container referenced under the link ``/redis``.
.. code-block:: bash .. code-block:: bash
$ sudo docker rm -link /webapp/redis $ sudo docker rm --link /webapp/redis
/webapp/redis /webapp/redis
@ -996,31 +997,31 @@ image is removed.
Run a command in a new container Run a command in a new container
-a=map[]: Attach to stdin, stdout or stderr -a, --attach=map[]: Attach to stdin, stdout or stderr
-c=0: CPU shares (relative weight) -c, --cpu-shares=0: CPU shares (relative weight)
-cidfile="": Write the container ID to the file --cidfile="": Write the container ID to the file
-d=false: Detached mode: Run container in the background, print new container id -d, --detach=false: Detached mode: Run container in the background, print new container id
-e=[]: Set environment variables -e, --env=[]: Set environment variables
-h="": Container host name -h, --host="": Container host name
-i=false: Keep stdin open even if not attached -i, --interactive=false: Keep stdin open even if not attached
-privileged=false: Give extended privileges to this container --privileged=false: Give extended privileges to this container
-m="": Memory limit (format: <number><optional unit>, where unit = b, k, m or g) -m, --memory="": Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
-n=true: Enable networking for this container -n, --networking=true: Enable networking for this container
-p=[]: Map a network port to the container -p, --publish=[]: Map a network port to the container
-rm=false: Automatically remove the container when it exits (incompatible with -d) --rm=false: Automatically remove the container when it exits (incompatible with -d)
-t=false: Allocate a pseudo-tty -t, --tty=false: Allocate a pseudo-tty
-u="": Username or UID -u, --username="": Username or UID
-dns=[]: Set custom dns servers for the container --dns=[]: Set custom dns servers for the container
-v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "container-dir" is missing, then docker creates a new volume. -v, --volume=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "container-dir" is missing, then docker creates a new volume.
-volumes-from="": Mount all volumes from the given container(s) --volumes-from="": Mount all volumes from the given container(s)
-entrypoint="": Overwrite the default entrypoint set by the image --entrypoint="": Overwrite the default entrypoint set by the image
-w="": Working directory inside the container -w, --workdir="": Working directory inside the container
-lxc-conf=[]: Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1" --lxc-conf=[]: Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
-sig-proxy=true: Proxify all received signal to the process (even in non-tty mode) --sig-proxy=true: Proxify all received signal to the process (even in non-tty mode)
-expose=[]: Expose a port from the container without publishing it to your host --expose=[]: Expose a port from the container without publishing it to your host
-link="": Add link to another container (name:alias) --link="": Add link to another container (name:alias)
-name="": Assign the specified name to the container. If no name is specific docker will generate a random name --name="": Assign the specified name to the container. If no name is specific docker will generate a random name
-P=false: Publish all exposed ports to the host interfaces -P, --publish-all=false: Publish all exposed ports to the host interfaces
The ``docker run`` command first ``creates`` a writeable container layer over The ``docker run`` command first ``creates`` a writeable container layer over
the specified image, and then ``starts`` it using the specified command. That the specified image, and then ``starts`` it using the specified command. That
@ -1042,7 +1043,7 @@ Examples:
.. code-block:: bash .. code-block:: bash
$ sudo docker run -cidfile /tmp/docker_test.cid ubuntu echo "test" $ sudo docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
This will create a container and print ``test`` to the console. The This will create a container and print ``test`` to the console. The
``cidfile`` flag makes Docker attempt to create a new file and write the ``cidfile`` flag makes Docker attempt to create a new file and write the
@ -1051,7 +1052,7 @@ error. Docker will close this file when ``docker run`` exits.
.. code-block:: bash .. code-block:: bash
$ sudo docker run -t -i -rm ubuntu bash $ sudo docker run -t -i --rm ubuntu bash
root@bc338942ef20:/# mount -t tmpfs none /mnt root@bc338942ef20:/# mount -t tmpfs none /mnt
mount: permission denied mount: permission denied
@ -1063,7 +1064,7 @@ allow it to run:
.. code-block:: bash .. code-block:: bash
$ sudo docker run -privileged ubuntu bash $ sudo docker run --privileged ubuntu bash
root@50e3f57e16e6:/# mount -t tmpfs none /mnt root@50e3f57e16e6:/# mount -t tmpfs none /mnt
root@50e3f57e16e6:/# df -h root@50e3f57e16e6:/# df -h
Filesystem Size Used Avail Use% Mounted on Filesystem Size Used Avail Use% Mounted on
@ -1104,7 +1105,7 @@ in Docker.
.. code-block:: bash .. code-block:: bash
$ sudo docker run -expose 80 ubuntu bash $ sudo docker run --expose 80 ubuntu bash
This exposes port ``80`` of the container for use within a link without 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` publishing the port to the host system's interfaces. :ref:`port_redirection`
@ -1112,28 +1113,28 @@ explains in detail how to manipulate ports in Docker.
.. code-block:: bash .. code-block:: bash
$ sudo docker run -name console -t -i ubuntu bash $ sudo 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
$ sudo docker run -link /redis:redis -name console ubuntu bash $ sudo 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.
.. code-block:: bash .. code-block:: bash
$ sudo docker run -volumes-from 777f7dc92da7,ba8c0c54f0f2:ro -i -t ubuntu pwd $ sudo docker run --volumes-from 777f7dc92da7,ba8c0c54f0f2:ro -i -t ubuntu pwd
The ``-volumes-from`` flag mounts all the defined volumes from the The ``--volumes-from`` flag mounts all the defined volumes from the
referenced containers. Containers can be specified by a comma seperated referenced containers. Containers can be specified by a comma seperated
list or by repetitions of the ``-volumes-from`` argument. The container list or by repetitions of the ``--volumes-from`` argument. The container
ID may be optionally suffixed with ``:ro`` or ``:rw`` to mount the volumes in 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 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. in the same mode (read write or read only) as the reference container.
@ -1143,11 +1144,11 @@ A complete example
.. code-block:: bash .. code-block:: bash
$ sudo docker run -d -name static static-web-files sh $ sudo docker run -d --name static static-web-files sh
$ sudo docker run -d -expose=8098 -name riak riakserver $ sudo docker run -d --expose=8098 --name riak riakserver
$ sudo docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro -name app appserver $ sudo docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro --name app appserver
$ sudo docker run -d -p 1443:443 -dns=dns.dev.org -v /var/log/httpd -volumes-from static -link riak -link app -h www.sven.dev.org -name web webserver $ sudo docker run -d -p 1443:443 --dns=dns.dev.org -v /var/log/httpd --volumes-from static --link riak --link app -h www.sven.dev.org --name web webserver
$ sudo docker run -t -i -rm -volumes-from web -w /var/log/httpd busybox tail -f access.log $ sudo docker run -t -i --rm --volumes-from web -w /var/log/httpd busybox tail -f access.log
This example shows 5 containers that might be set up to test a web application change: This example shows 5 containers that might be set up to test a web application change:
@ -1181,9 +1182,9 @@ This example shows 5 containers that might be set up to test a web application c
Search the docker index for images Search the docker index for images
-notrunc=false: Don't truncate output --no-trunc=false: Don't truncate output
-stars=0: Only displays with at least xxx stars -s, --stars=0: Only displays with at least xxx stars
-trusted=false: Only show trusted builds -t, --trusted=false: Only show trusted builds
.. _cli_start: .. _cli_start:
@ -1196,8 +1197,8 @@ This example shows 5 containers that might be set up to test a web application c
Start a stopped container Start a stopped container
-a=false: Attach container's stdout/stderr and forward all signals to the process -a, --attach=false: Attach container's stdout/stderr and forward all signals to the process
-i=false: Attach container's stdin -i, --interactive=false: Attach container's stdin
.. _cli_stop: .. _cli_stop:
@ -1210,7 +1211,7 @@ This example shows 5 containers that might be set up to test a web application c
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, --time=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
@ -1225,7 +1226,7 @@ The main process inside the container will receive SIGTERM, and after a grace pe
Tag an image into a repository Tag an image into a repository
-f=false: Force -f, --force=false: Force
.. _cli_top: .. _cli_top: