Merge pull request #3062 from SvenDowideit/cli-examples-dollar-sudo-docker

Some examples didnt use $ sudo docker, so this makes it a little more consistent
This commit is contained in:
Andy Rothfusz 2013-12-05 15:25:09 -08:00
commit 0189a99471

View file

@ -143,7 +143,7 @@ Examples:
.. code-block:: bash
sudo docker build .
$ sudo docker build .
Uploading context 10240 bytes
Step 1 : FROM busybox
Pulling repository busybox
@ -183,7 +183,7 @@ message.
.. code-block:: bash
sudo docker build -t vieux/apache:2.0 .
$ sudo docker build -t vieux/apache:2.0 .
This will build like the previous example, but it will then tag the
resulting image. The repository name will be ``vieux/apache`` and the
@ -192,7 +192,7 @@ tag will be ``2.0``
.. code-block:: bash
sudo docker build - < Dockerfile
$ sudo docker build - < Dockerfile
This will read a ``Dockerfile`` from *stdin* without context. Due to
the lack of a context, no contents of any local directory will be sent
@ -201,7 +201,7 @@ to the ``docker`` daemon. Since there is no context, a Dockerfile
.. code-block:: bash
sudo docker build github.com/creack/docker-firefox
$ sudo docker build github.com/creack/docker-firefox
This will clone the Github repository and use the cloned repository as
context. The ``Dockerfile`` at the root of the repository is used as
@ -230,7 +230,7 @@ Simple commit of an existing container
.. code-block:: bash
$ docker ps
$ sudo docker ps
ID IMAGE COMMAND CREATED STATUS PORTS
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
@ -678,7 +678,7 @@ fairly straightforward manner.
.. code-block:: bash
docker inspect -format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
$ sudo docker inspect -format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
List All Port Bindings
......................
@ -688,13 +688,11 @@ text output:
.. code-block:: bash
docker inspect -format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
$ sudo docker inspect -format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
Find a Specific Port Mapping
............................
.. code-block:: bash
The ``.Field`` syntax doesn't work when the field name begins with a
number, but the template language's ``index`` function does. The
``.NetworkSettings.Ports`` section contains a map of the internal port
@ -705,7 +703,7 @@ we ask for the ``HostPort`` field to get the public address.
.. code-block:: bash
docker inspect -format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
$ sudo docker inspect -format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
.. _cli_kill:
@ -867,7 +865,7 @@ Examples:
.. code-block:: bash
$ docker rm /redis
$ sudo docker rm /redis
/redis
@ -876,7 +874,7 @@ This will remove the container referenced under the link ``/redis``.
.. code-block:: bash
$ docker rm -link /webapp/redis
$ sudo docker rm -link /webapp/redis
/webapp/redis
@ -885,7 +883,7 @@ network communication.
.. code-block:: bash
$ docker rm `docker ps -a -q`
$ sudo docker rm `docker ps -a -q`
This command will delete all stopped containers. The command ``docker ps -a -q`` will return all
@ -952,7 +950,7 @@ Examples:
.. 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
``cidfile`` flag makes docker attempt to create a new file and write the
@ -961,7 +959,10 @@ error. Docker will close this file when docker run exits.
.. code-block:: bash
docker run mount -t tmpfs none /var/spool/squid
$ sudo docker run -t -i -rm ubuntu bash
root@bc338942ef20:/# mount -t tmpfs none /mnt
mount: permission denied
This will *not* work, because by default, most potentially dangerous
kernel capabilities are dropped; including ``cap_sys_admin`` (which is
@ -970,7 +971,12 @@ allow it to run:
.. code-block:: bash
docker run -privileged mount -t tmpfs none /var/spool/squid
$ sudo docker run -privileged ubuntu bash
root@50e3f57e16e6:/# mount -t tmpfs none /mnt
root@50e3f57e16e6:/# df -h
Filesystem Size Used Avail Use% Mounted on
none 1.9G 0 1.9G 0% /mnt
The ``-privileged`` flag gives *all* capabilities to the container,
and it also lifts all the limitations enforced by the ``device``
@ -980,7 +986,7 @@ use-cases, like running Docker within Docker.
.. code-block:: bash
docker run -w /path/to/dir/ -i -t ubuntu pwd
$ sudo 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
@ -988,7 +994,7 @@ container.
.. code-block:: bash
docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
$ sudo 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
@ -998,7 +1004,7 @@ using the container, but inside the current working directory.
.. code-block:: bash
docker run -p 127.0.0.1:80:8080 ubuntu bash
$ sudo docker run -p 127.0.0.1:80:8080 ubuntu bash
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
@ -1006,7 +1012,7 @@ in Docker.
.. code-block:: bash
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
publishing the port to the host system's interfaces. :ref:`port_redirection`
@ -1014,14 +1020,14 @@ explains in detail how to manipulate ports in Docker.
.. code-block:: bash
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
being ``console``.
.. code-block:: bash
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
newly created container with the alias ``redis``. The new container
@ -1031,7 +1037,7 @@ to the newly created container.
.. code-block:: bash
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
refrence containers. Containers can be specified by a comma seperated