Browse code

Fix #1517, #1521 by adding sudo to examples and installation.

Andy Rothfusz authored on 2013/08/14 10:05:35
Showing 26 changed files
... ...
@@ -13,7 +13,7 @@ Docker Usage
13 13
 To list available commands, either run ``docker`` with no parameters or execute
14 14
 ``docker help``::
15 15
 
16
-  $ docker
16
+  $ sudo docker
17 17
     Usage: docker [OPTIONS] COMMAND [arg...]
18 18
       -H=[tcp://127.0.0.1:4243]: tcp://host:port to bind/connect to or unix://path/to/socket to use
19 19
 
... ...
@@ -21,32 +21,44 @@ Examples
21 21
 
22 22
 .. code-block:: bash
23 23
 
24
-    docker build .
24
+    sudo docker build .
25 25
 
26
-| This will read the Dockerfile from the current directory. It will also send any other files and directories found in the current directory to the docker daemon.
27
-| The contents of this directory would be used by ADD commands found within the Dockerfile.
28
-| This will send a lot of data to the docker daemon if the current directory contains a lot of data.
29
-| If the absolute path is provided instead of '.', only the files and directories required by the ADD commands from the Dockerfile will be added to the context and transferred to the docker daemon.
30
-|
26
+This will read the ``Dockerfile`` from the current directory. It will
27
+also send any other files and directories found in the current
28
+directory to the ``docker`` daemon.
29
+
30
+The contents of this directory would be used by ``ADD`` commands found
31
+within the ``Dockerfile``.  This will send a lot of data to the
32
+``docker`` daemon if the current directory contains a lot of data.  If
33
+the absolute path is provided instead of ``.`` then only the files and
34
+directories required by the ADD commands from the ``Dockerfile`` will be
35
+added to the context and transferred to the ``docker`` daemon.
31 36
 
32 37
 .. code-block:: bash
33 38
 
34
-   docker build -t vieux/apache:2.0 .
39
+   sudo docker build -t vieux/apache:2.0 .
35 40
 
36
-| This will build like the preview example, but it will then tag the resulting image, the repository name will be 'vieux/apache' and the tag will be '2.0'
41
+This will build like the previous example, but it will then tag the
42
+resulting image. The repository name will be ``vieux/apache`` and the
43
+tag will be ``2.0``
37 44
 
38 45
 
39 46
 .. code-block:: bash
40 47
 
41
-    docker build - < Dockerfile
48
+    sudo docker build - < Dockerfile
42 49
 
43
-| 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 to the docker daemon.
44
-| ADD doesn't work when running in this mode due to the absence of the context, thus having no source files to copy to the container.
50
+This will read a ``Dockerfile`` from *stdin* without context. Due to
51
+the lack of a context, no contents of any local directory will be sent
52
+to the ``docker`` daemon.  ``ADD`` doesn't work when running in this
53
+mode because the absence of the context provides no source files to
54
+copy to the container.
45 55
 
46 56
 
47 57
 .. code-block:: bash
48 58
 
49
-    docker build github.com/creack/docker-firefox
59
+    sudo docker build github.com/creack/docker-firefox
50 60
 
51
-| This will clone the github repository and use it as context. The Dockerfile at the root of the repository is used as Dockerfile.
52
-| Note that you can specify an arbitrary git repository by using the 'git://' schema.
61
+This will clone the Github repository and use it as context. The
62
+``Dockerfile`` at the root of the repository is used as
63
+``Dockerfile``.  Note that you can specify an arbitrary git repository
64
+by using the ``git://`` schema.
... ...
@@ -14,7 +14,8 @@
14 14
 
15 15
       -m="": Commit message
16 16
       -author="": Author (eg. "John Hannibal Smith <hannibal@a-team.com>"
17
-      -run="": Config automatically applied when the image is run. "+`(ex: {"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
17
+      -run="": Config automatically applied when the image is
18
+       run. "+`(ex: {"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
18 19
 
19 20
 Full -run example::
20 21
 
... ...
@@ -21,6 +21,6 @@ Displaying images visually
21 21
 
22 22
 ::
23 23
 
24
-    docker images -viz | dot -Tpng -o docker.png
24
+    sudo docker images -viz | dot -Tpng -o docker.png
25 25
 
26 26
 .. image:: images/docker_images.gif
... ...
@@ -12,10 +12,11 @@
12 12
 
13 13
     Create a new filesystem image from the contents of a tarball
14 14
 
15
-At this time, the URL must start with ``http`` and point to a single file archive
16
-(.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz)
17
-containing a root filesystem. If you would like to import from a local directory or archive,
18
-you can use the ``-`` parameter to take the data from standard in.
15
+At this time, the URL must start with ``http`` and point to a single
16
+file archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) containing a
17
+root filesystem. If you would like to import from a local directory or
18
+archive, you can use the ``-`` parameter to take the data from
19
+standard in.
19 20
 
20 21
 Examples
21 22
 --------
... ...
@@ -23,19 +24,21 @@ Examples
23 23
 Import from a remote location
24 24
 .............................
25 25
 
26
-``$ docker import http://example.com/exampleimage.tgz exampleimagerepo``
26
+``$ sudo docker import http://example.com/exampleimage.tgz exampleimagerepo``
27 27
 
28 28
 Import from a local file
29 29
 ........................
30 30
 
31 31
 Import to docker via pipe and standard in
32 32
 
33
-``$ cat exampleimage.tgz | docker import - exampleimagelocal``
33
+``$ cat exampleimage.tgz | sudo docker import - exampleimagelocal``
34 34
 
35 35
 Import from a local directory
36 36
 .............................
37 37
 
38 38
 ``$ sudo tar -c . | docker import - exampleimagedir``
39 39
 
40
-Note the ``sudo`` in this example -- you must preserve the ownership of the files (especially root ownership)
41
-during the archiving with tar. If you are not root (or sudo) when you tar, then the ownerships might not get preserved.
40
+Note the ``sudo`` in this example -- you must preserve the ownership
41
+of the files (especially root ownership) during the archiving with
42
+tar. If you are not root (or sudo) when you tar, then the ownerships
43
+might not get preserved.
... ...
@@ -36,18 +36,29 @@ Examples
36 36
 
37 37
 .. code-block:: bash
38 38
 
39
-    docker run -cidfile /tmp/docker_test.cid ubuntu echo "test"
39
+    sudo docker run -cidfile /tmp/docker_test.cid ubuntu echo "test"
40 40
 
41
-| 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 container ID to it. If the file exists already, docker will return an error. Docker will close this file when docker run exits.
41
+This will create a container and print "test" to the console. The
42
+``cidfile`` flag makes docker attempt to create a new file and write the
43
+container ID to it. If the file exists already, docker will return an
44
+error. Docker will close this file when docker run exits.
42 45
 
43 46
 .. code-block:: bash
44 47
 
45 48
    docker run mount -t tmpfs none /var/spool/squid
46 49
 
47
-| This will *not* work, because by default, most potentially dangerous kernel capabilities are dropped; including  ``cap_sys_admin`` (which is required to mount filesystems). However, the ``-privileged`` flag will allow it to run:
50
+This will *not* work, because by default, most potentially dangerous
51
+kernel capabilities are dropped; including ``cap_sys_admin`` (which is
52
+required to mount filesystems). However, the ``-privileged`` flag will
53
+allow it to run:
48 54
 
49 55
 .. code-block:: bash
50 56
 
51 57
    docker run -privileged mount -t tmpfs none /var/spool/squid
52 58
 
53
-| The ``-privileged`` flag gives *all* capabilities to the container, and it also lifts all the limitations enforced by the ``device`` cgroup controller. In other words, the container can then do almost everything that the host can do. This flag exists to allow special use-cases, like running Docker within Docker.
59
+The ``-privileged`` flag gives *all* capabilities to the container,
60
+and it also lifts all the limitations enforced by the ``device``
61
+cgroup controller. In other words, the container can then do almost
62
+everything that the host can do. This flag exists to allow special
63
+use-cases, like running Docker within Docker.
64
+
... ...
@@ -10,5 +10,5 @@
10 10
 
11 11
     Usage: docker search TERM
12 12
 
13
-    Searches for the TERM parameter on the Docker index and prints out a list of repositories
14
-    that match.
13
+    Searches for the TERM parameter on the Docker index and prints out
14
+    a list of repositories that match.
... ...
@@ -5,18 +5,23 @@
5 5
 Setting Up a Dev Environment
6 6
 ============================
7 7
 
8
-To make it easier to contribute to Docker, we provide a standard development environment. It is important that
9
-the same environment be used for all tests, builds and releases. The standard development environment defines
10
-all build dependencies: system libraries and binaries, go environment, go dependencies, etc.
8
+To make it easier to contribute to Docker, we provide a standard
9
+development environment. It is important that the same environment be
10
+used for all tests, builds and releases. The standard development
11
+environment defines all build dependencies: system libraries and
12
+binaries, go environment, go dependencies, etc.
11 13
 
12 14
 
13 15
 Step 1: install docker
14 16
 ----------------------
15 17
 
16
-Docker's build environment itself is a docker container, so the first step is to install docker on your system.
18
+Docker's build environment itself is a Docker container, so the first
19
+step is to install docker on your system.
17 20
 
18
-You can follow the `install instructions most relevant to your system <https://docs.docker.io/en/latest/installation/>`.
19
-Make sure you have a working, up-to-date docker installation, then continue to the next step.
21
+You can follow the `install instructions most relevant to your system
22
+<https://docs.docker.io/en/latest/installation/>`_.  Make sure you have
23
+a working, up-to-date docker installation, then continue to the next
24
+step.
20 25
 
21 26
 
22 27
 Step 2: check out the source
... ...
@@ -35,24 +40,24 @@ When you are ready to build docker, run this command:
35 35
 
36 36
 ::
37 37
 
38
-    docker build -t docker .
38
+    sudo docker build -t docker .
39 39
 
40
-This will build the revision currently checked out in the repository. Feel free to check out the version
41
-of your choice.
40
+This will build the revision currently checked out in the
41
+repository. Feel free to check out the version of your choice.
42 42
 
43
-If the build is successful, congratulations! You have produced a clean build of docker, neatly encapsulated
44
-in a standard build environment.
43
+If the build is successful, congratulations! You have produced a clean
44
+build of docker, neatly encapsulated in a standard build environment.
45 45
 
46 46
 You can run an interactive session in the newly built container:
47 47
 
48 48
 ::
49 49
 
50
-    docker run -i -t docker bash
50
+    sudo docker run -i -t docker bash
51 51
 
52 52
 
53 53
 To extract the binaries from the container:
54 54
 
55 55
 ::
56 56
 
57
-    docker run docker sh -c 'cat $(which docker)' > docker-build && chmod +x docker-build
57
+    sudo docker run docker sh -c 'cat $(which docker)' > docker-build && chmod +x docker-build
58 58
 
... ...
@@ -9,27 +9,29 @@ CouchDB Service
9 9
 
10 10
 .. include:: example_header.inc
11 11
 
12
-Here's an example of using data volumes to share the same data between 2 couchdb containers.
13
-This could be used for hot upgrades, testing different versions of couchdb on the same data, etc.
12
+Here's an example of using data volumes to share the same data between
13
+2 CouchDB containers.  This could be used for hot upgrades, testing
14
+different versions of CouchDB on the same data, etc.
14 15
 
15 16
 Create first database
16 17
 ---------------------
17 18
 
18
-Note that we're marking /var/lib/couchdb as a data volume.
19
+Note that we're marking ``/var/lib/couchdb`` as a data volume.
19 20
 
20 21
 .. code-block:: bash
21 22
 
22
-    COUCH1=$(docker run -d -v /var/lib/couchdb shykes/couchdb:2013-05-03)
23
+    COUCH1=$(sudo docker run -d -v /var/lib/couchdb shykes/couchdb:2013-05-03)
23 24
 
24 25
 Add data to the first database
25 26
 ------------------------------
26 27
 
27
-We're assuming your docker host is reachable at `localhost`. If not, replace `localhost` with the public IP of your docker host.
28
+We're assuming your docker host is reachable at `localhost`. If not,
29
+replace `localhost` with the public IP of your docker host.
28 30
 
29 31
 .. code-block:: bash
30 32
 
31 33
     HOST=localhost
32
-    URL="http://$HOST:$(docker port $COUCH1 5984)/_utils/"
34
+    URL="http://$HOST:$(sudo docker port $COUCH1 5984)/_utils/"
33 35
     echo "Navigate to $URL in your browser, and use the couch interface to add data"
34 36
 
35 37
 Create second database
... ...
@@ -39,7 +41,7 @@ This time, we're requesting shared access to $COUCH1's volumes.
39 39
 
40 40
 .. code-block:: bash
41 41
 
42
-    COUCH2=$(docker run -d -volumes-from $COUCH1 shykes/couchdb:2013-05-03)
42
+    COUCH2=$(sudo docker run -d -volumes-from $COUCH1 shykes/couchdb:2013-05-03)
43 43
 
44 44
 Browse data on the second database
45 45
 ----------------------------------
... ...
@@ -47,7 +49,8 @@ Browse data on the second database
47 47
 .. code-block:: bash
48 48
 
49 49
     HOST=localhost
50
-    URL="http://$HOST:$(docker port $COUCH2 5984)/_utils/"
50
+    URL="http://$HOST:$(sudo docker port $COUCH2 5984)/_utils/"
51 51
     echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!'
52 52
 
53
-Congratulations, you are running 2 Couchdb containers, completely isolated from each other *except* for their data.
53
+Congratulations, you are running 2 Couchdb containers, completely
54
+isolated from each other *except* for their data.
... ...
@@ -11,26 +11,28 @@ Hello World
11 11
 
12 12
 This is the most basic example available for using Docker.
13 13
 
14
-Download the base container
14
+Download the base image (named "ubuntu"):
15 15
 
16 16
 .. code-block:: bash
17 17
 
18 18
     # Download an ubuntu image
19
-    docker pull ubuntu
19
+    sudo docker pull ubuntu
20 20
 
21
-The *base* image is a minimal *ubuntu* based container, alternatively you can select *busybox*, a bare
22
-minimal linux system. The images are retrieved from the docker repository.
21
+Alternatively to the *ubuntu* image, you can select *busybox*, a bare
22
+minimal Linux system. The images are retrieved from the Docker
23
+repository.
23 24
 
24 25
 
25 26
 .. code-block:: bash
26 27
 
27 28
     #run a simple echo command, that will echo hello world back to the console over standard out.
28
-    docker run base /bin/echo hello world
29
+    sudo docker run ubuntu /bin/echo hello world
29 30
 
30 31
 **Explanation:**
31 32
 
33
+- **"sudo"** execute the following commands as user *root* 
32 34
 - **"docker run"** run a command in a new container 
33
-- **"base"** is the image we want to run the command inside of.
35
+- **"ubuntu"** is the image we want to run the command inside of.
34 36
 - **"/bin/echo"** is the command we want to run in the container
35 37
 - **"hello world"** is the input for the echo command
36 38
 
... ...
@@ -11,27 +11,35 @@ Hello World Daemon
11 11
 
12 12
 The most boring daemon ever written.
13 13
 
14
-This example assumes you have Docker installed and with the ubuntu image already imported ``docker pull ubuntu``.
15
-We will use the ubuntu image to run a simple hello world daemon that will just print hello world to standard
16
-out every second. It will continue to do this until we stop it.
14
+This example assumes you have Docker installed and with the Ubuntu
15
+image already imported ``docker pull ubuntu``.  We will use the Ubuntu
16
+image to run a simple hello world daemon that will just print hello
17
+world to standard out every second. It will continue to do this until
18
+we stop it.
17 19
 
18 20
 **Steps:**
19 21
 
20 22
 .. code-block:: bash
21 23
 
22
-    CONTAINER_ID=$(docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done")
24
+    CONTAINER_ID=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done")
23 25
 
24
-We are going to run a simple hello world daemon in a new container made from the ubuntu image.
26
+We are going to run a simple hello world daemon in a new container
27
+made from the *ubuntu* image.
25 28
 
26
-- **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon.
29
+- **"docker run -d "** run a command in a new container. We pass "-d"
30
+  so it runs as a daemon.
27 31
 - **"ubuntu"** is the image we want to run the command inside of.
28 32
 - **"/bin/sh -c"** is the command we want to run in the container
29
-- **"while true; do echo hello world; sleep 1; done"** is the mini script we want to run, that will just print hello world once a second until we stop it.
30
-- **$CONTAINER_ID** the output of the run command will return a container id, we can use in future commands to see what is going on with this process.
33
+- **"while true; do echo hello world; sleep 1; done"** is the mini
34
+  script we want to run, that will just print hello world once a
35
+  second until we stop it.
36
+- **$CONTAINER_ID** the output of the run command will return a
37
+  container id, we can use in future commands to see what is going on
38
+  with this process.
31 39
 
32 40
 .. code-block:: bash
33 41
 
34
-    docker logs $CONTAINER_ID
42
+    sudo docker logs $CONTAINER_ID
35 43
 
36 44
 Check the logs make sure it is working correctly.
37 45
 
... ...
@@ -40,16 +48,17 @@ Check the logs make sure it is working correctly.
40 40
 
41 41
 .. code-block:: bash
42 42
 
43
-    docker attach $CONTAINER_ID
43
+    sudo docker attach $CONTAINER_ID
44 44
 
45 45
 Attach to the container to see the results in realtime.
46 46
 
47
-- **"docker attach**" This will allow us to attach to a background process to see what is going on.
47
+- **"docker attach**" This will allow us to attach to a background
48
+  process to see what is going on.
48 49
 - **$CONTAINER_ID** The Id of the container we want to attach too.
49 50
 
50 51
 .. code-block:: bash
51 52
 
52
-    docker ps
53
+    sudo docker ps
53 54
 
54 55
 Check the process list to make sure it is running.
55 56
 
... ...
@@ -57,7 +66,7 @@ Check the process list to make sure it is running.
57 57
 
58 58
 .. code-block:: bash
59 59
 
60
-    docker stop $CONTAINER_ID
60
+    sudo docker stop $CONTAINER_ID
61 61
 
62 62
 Stop the container, since we don't need it anymore.
63 63
 
... ...
@@ -66,7 +75,7 @@ Stop the container, since we don't need it anymore.
66 66
 
67 67
 .. code-block:: bash
68 68
 
69
-    docker ps
69
+    sudo docker ps
70 70
 
71 71
 Make sure it is really stopped.
72 72
 
... ...
@@ -9,10 +9,11 @@ Node.js Web App
9 9
 
10 10
 .. include:: example_header.inc
11 11
 
12
-The goal of this example is to show you how you can build your own docker images
13
-from a parent image using a ``Dockerfile`` . We will do that by making a simple
14
-Node.js hello world web application running on CentOS. You can get the full
15
-source code at https://github.com/gasi/docker-node-hello.
12
+The goal of this example is to show you how you can build your own
13
+docker images from a parent image using a ``Dockerfile`` . We will do
14
+that by making a simple Node.js hello world web application running on
15
+CentOS. You can get the full source code at
16
+https://github.com/gasi/docker-node-hello.
16 17
 
17 18
 Create Node.js app
18 19
 ++++++++++++++++++
... ...
@@ -109,16 +110,17 @@ Install your app dependencies using npm:
109 109
     # Install app dependencies
110 110
     RUN cd /src; npm install
111 111
 
112
-Your app binds to port ``8080`` so you’ll use the ``EXPOSE`` command to have it
113
-mapped by the docker daemon:
112
+Your app binds to port ``8080`` so you’ll use the ``EXPOSE`` command
113
+to have it mapped by the docker daemon:
114 114
 
115 115
 .. code-block:: bash
116 116
 
117 117
     EXPOSE  8080
118 118
 
119
-Last but not least, define the command to run your app using ``CMD`` which
120
-defines your runtime, i.e. ``node``, and the path to our app, i.e.
121
-``src/index.js`` (see the step where we added the source to the container):
119
+Last but not least, define the command to run your app using ``CMD``
120
+which defines your runtime, i.e. ``node``, and the path to our app,
121
+i.e.  ``src/index.js`` (see the step where we added the source to the
122
+container):
122 123
 
123 124
 .. code-block:: bash
124 125
 
... ...
@@ -149,19 +151,20 @@ Your ``Dockerfile`` should now look like this:
149 149
 Building your image
150 150
 +++++++++++++++++++
151 151
 
152
-Go to the directory that has your ``Dockerfile`` and run the following command
153
-to build a docker image. The ``-t`` flag let’s you tag your image so it’s easier
154
-to find later using the ``docker images`` command:
152
+Go to the directory that has your ``Dockerfile`` and run the following
153
+command to build a docker image. The ``-t`` flag let’s you tag your
154
+image so it’s easier to find later using the ``docker images``
155
+command:
155 156
 
156 157
 .. code-block:: bash
157 158
 
158
-    docker build -t <your username>/centos-node-hello .
159
+    sudo docker build -t <your username>/centos-node-hello .
159 160
 
160 161
 Your image will now be listed by docker:
161 162
 
162 163
 .. code-block:: bash
163 164
 
164
-    docker images
165
+    sudo docker images
165 166
 
166 167
     > # Example
167 168
     > REPOSITORY                 TAG       ID              CREATED
... ...
@@ -177,17 +180,17 @@ container running in the background. Run the image you previously built:
177 177
 
178 178
 .. code-block:: bash
179 179
 
180
-    docker run -d <your username>/centos-node-hello
180
+    sudo docker run -d <your username>/centos-node-hello
181 181
 
182 182
 Print the output of your app:
183 183
 
184 184
 .. code-block:: bash
185 185
 
186 186
     # Get container ID
187
-    docker ps
187
+    sudo docker ps
188 188
 
189 189
     # Print app output
190
-    docker logs <container id>
190
+    sudo docker logs <container id>
191 191
 
192 192
     > # Example
193 193
     > Running on http://localhost:8080
... ...
@@ -225,8 +228,8 @@ Now you can call your app using ``curl`` (install if needed via:
225 225
     >
226 226
     > Hello World
227 227
 
228
-We hope this tutorial helped you get up and running with Node.js and CentOS on
229
-docker. You can get the full source code at
228
+We hope this tutorial helped you get up and running with Node.js and
229
+CentOS on docker. You can get the full source code at
230 230
 https://github.com/gasi/docker-node-hello.
231 231
 
232 232
 Continue to :ref:`running_redis_service`.
... ...
@@ -31,7 +31,7 @@ Run an interactive shell in Docker container.
31 31
 
32 32
 .. code-block:: bash
33 33
 
34
-    docker run -i -t ubuntu /bin/bash
34
+    sudo docker run -i -t ubuntu /bin/bash
35 35
 
36 36
 Update its dependencies.
37 37
 
... ...
@@ -60,9 +60,9 @@ Finally, install PostgreSQL 9.2
60 60
 
61 61
     apt-get -y install postgresql-9.2 postgresql-client-9.2 postgresql-contrib-9.2
62 62
 
63
-Now, create a PostgreSQL superuser role that can create databases and other roles.
64
-Following Vagrant's convention the role will be named `docker` with `docker`
65
-password assigned to it.
63
+Now, create a PostgreSQL superuser role that can create databases and
64
+other roles.  Following Vagrant's convention the role will be named
65
+`docker` with `docker` password assigned to it.
66 66
 
67 67
 .. code-block:: bash
68 68
 
... ...
@@ -75,27 +75,27 @@ role.
75 75
 
76 76
     sudo -u postgres createdb -O docker docker
77 77
 
78
-Adjust PostgreSQL configuration so that remote connections to the database are
79
-possible. Make sure that inside ``/etc/postgresql/9.2/main/pg_hba.conf`` you have
80
-following line:
78
+Adjust PostgreSQL configuration so that remote connections to the
79
+database are possible. Make sure that inside
80
+``/etc/postgresql/9.2/main/pg_hba.conf`` you have following line:
81 81
 
82 82
 .. code-block:: bash
83 83
 
84 84
     host    all             all             0.0.0.0/0               md5
85 85
 
86
-Additionaly, inside ``/etc/postgresql/9.2/main/postgresql.conf`` uncomment
87
-``listen_address`` so it is as follows:
86
+Additionaly, inside ``/etc/postgresql/9.2/main/postgresql.conf``
87
+uncomment ``listen_address`` so it is as follows:
88 88
 
89 89
 .. code-block:: bash
90 90
 
91 91
     listen_address='*'
92 92
 
93
-*Note:* this PostgreSQL setup is for development only purposes. Refer to
94
-PostgreSQL documentation how to fine-tune these settings so that it is enough
95
-secure.
93
+*Note:* this PostgreSQL setup is for development only purposes. Refer
94
+to PostgreSQL documentation how to fine-tune these settings so that it
95
+is enough secure.
96 96
 
97
-Create an image and assign it a name. ``<container_id>`` is in the Bash prompt;
98
-you can also locate it using ``docker ps -a``.
97
+Create an image and assign it a name. ``<container_id>`` is in the
98
+Bash prompt; you can also locate it using ``docker ps -a``.
99 99
 
100 100
 .. code-block:: bash
101 101
 
... ...
@@ -105,7 +105,7 @@ Finally, run PostgreSQL server via ``docker``.
105 105
 
106 106
 .. code-block:: bash
107 107
 
108
-    CONTAINER=$(docker run -d -p 5432 \
108
+    CONTAINER=$(sudo docker run -d -p 5432 \
109 109
       -t <your username>/postgresql \
110 110
       /bin/su postgres -c '/usr/lib/postgresql/9.2/bin/postgres \
111 111
         -D /var/lib/postgresql/9.2/main \
... ...
@@ -115,7 +115,7 @@ Connect the PostgreSQL server using ``psql``.
115 115
 
116 116
 .. code-block:: bash
117 117
 
118
-    CONTAINER_IP=$(docker inspect $CONTAINER | grep IPAddress | awk '{ print $2 }' | tr -d ',"')
118
+    CONTAINER_IP=$(sudo docker inspect $CONTAINER | grep IPAddress | awk '{ print $2 }' | tr -d ',"')
119 119
     psql -h $CONTAINER_IP -p 5432 -d docker -U docker -W
120 120
 
121 121
 As before, create roles or databases if needed.
... ...
@@ -132,13 +132,13 @@ Additionally, publish there your newly created image on Docker Index.
132 132
 
133 133
 .. code-block:: bash
134 134
 
135
-    docker login
135
+    sudo docker login
136 136
     Username: <your username>
137 137
     [...]
138 138
 
139 139
 .. code-block:: bash
140 140
 
141
-    docker push <your username>/postgresql
141
+    sudo docker push <your username>/postgresql
142 142
 
143 143
 PostgreSQL service auto-launch
144 144
 ------------------------------
... ...
@@ -149,10 +149,10 @@ container starts.
149 149
 
150 150
 .. code-block:: bash
151 151
 
152
-    docker commit <container_id> <your username>/postgresql -run='{"Cmd": \
152
+    sudo docker commit <container_id> <your username>/postgresql -run='{"Cmd": \
153 153
       ["/bin/su", "postgres", "-c", "/usr/lib/postgresql/9.2/bin/postgres -D \
154 154
       /var/lib/postgresql/9.2/main -c \
155 155
       config_file=/etc/postgresql/9.2/main/postgresql.conf"], PortSpecs": ["5432"]}
156 156
 
157
-From now on, just type ``docker run <your username>/postgresql`` and PostgreSQL
158
-should automatically start.
157
+From now on, just type ``docker run <your username>/postgresql`` and
158
+PostgreSQL should automatically start.
... ...
@@ -9,13 +9,16 @@ Python Web App
9 9
 
10 10
 .. include:: example_header.inc
11 11
 
12
-The goal of this example is to show you how you can author your own docker images using a parent image, making changes to it, and then saving the results as a new image. We will do that by making a simple hello flask web application image.
12
+The goal of this example is to show you how you can author your own
13
+docker images using a parent image, making changes to it, and then
14
+saving the results as a new image. We will do that by making a simple
15
+hello flask web application image.
13 16
 
14 17
 **Steps:**
15 18
 
16 19
 .. code-block:: bash
17 20
 
18
-    docker pull shykes/pybuilder
21
+    sudo docker pull shykes/pybuilder
19 22
 
20 23
 We are downloading the "shykes/pybuilder" docker image
21 24
 
... ...
@@ -27,52 +30,66 @@ We set a URL variable that points to a tarball of a simple helloflask web app
27 27
 
28 28
 .. code-block:: bash
29 29
 
30
-    BUILD_JOB=$(docker run -d -t shykes/pybuilder:latest /usr/local/bin/buildapp $URL)
30
+    BUILD_JOB=$(sudo docker run -d -t shykes/pybuilder:latest /usr/local/bin/buildapp $URL)
31 31
 
32
-Inside of the "shykes/pybuilder" image there is a command called buildapp, we are running that command and passing the $URL variable from step 2 to it, and running the whole thing inside of a new container. BUILD_JOB will be set with the new container_id.
32
+Inside of the "shykes/pybuilder" image there is a command called
33
+buildapp, we are running that command and passing the $URL variable
34
+from step 2 to it, and running the whole thing inside of a new
35
+container. BUILD_JOB will be set with the new container_id.
33 36
 
34 37
 .. code-block:: bash
35 38
 
36
-    docker attach $BUILD_JOB
39
+    sudo docker attach $BUILD_JOB
37 40
     [...]
38 41
 
39
-While this container is running, we can attach to the new container to see what is going on. Ctrl-C to disconnect.
42
+While this container is running, we can attach to the new container to
43
+see what is going on. Ctrl-C to disconnect.
40 44
 
41 45
 .. code-block:: bash
42 46
 
43
-    docker ps -a
47
+    sudo docker ps -a
44 48
     
45
-List all docker containers. If this container has already finished running, it will still be listed here.
49
+List all docker containers. If this container has already finished
50
+running, it will still be listed here.
46 51
 
47 52
 .. code-block:: bash
48 53
 
49
-    BUILD_IMG=$(docker commit $BUILD_JOB _/builds/github.com/shykes/helloflask/master)
54
+    BUILD_IMG=$(sudo docker commit $BUILD_JOB _/builds/github.com/shykes/helloflask/master)
50 55
 
51
-Save the changes we just made in the container to a new image called "_/builds/github.com/hykes/helloflask/master" and save the image id in the BUILD_IMG variable name.
56
+Save the changes we just made in the container to a new image called
57
+``_/builds/github.com/hykes/helloflask/master`` and save the image id in
58
+the BUILD_IMG variable name.
52 59
 
53 60
 .. code-block:: bash
54 61
 
55
-    WEB_WORKER=$(docker run -d -p 5000 $BUILD_IMG /usr/local/bin/runapp)
62
+    WEB_WORKER=$(sudo docker run -d -p 5000 $BUILD_IMG /usr/local/bin/runapp)
56 63
 
57
-- **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon.
58
-- **"-p 5000"** the web app is going to listen on this port, so it must be mapped from the container to the host system.
64
+- **"docker run -d "** run a command in a new container. We pass "-d"
65
+  so it runs as a daemon.
66
+- **"-p 5000"** the web app is going to listen on this port, so it
67
+  must be mapped from the container to the host system.
59 68
 - **"$BUILD_IMG"** is the image we want to run the command inside of.
60 69
 - **/usr/local/bin/runapp** is the command which starts the web app.
61 70
 
62
-Use the new image we just created and create a new container with network port 5000, and return the container id and store in the WEB_WORKER variable.
71
+Use the new image we just created and create a new container with
72
+network port 5000, and return the container id and store in the
73
+WEB_WORKER variable.
63 74
 
64 75
 .. code-block:: bash
65 76
 
66
-    docker logs $WEB_WORKER
77
+    sudo docker logs $WEB_WORKER
67 78
      * Running on http://0.0.0.0:5000/
68 79
 
69
-View the logs for the new container using the WEB_WORKER variable, and if everything worked as planned you should see the line "Running on http://0.0.0.0:5000/" in the log output.
80
+View the logs for the new container using the WEB_WORKER variable, and
81
+if everything worked as planned you should see the line "Running on
82
+http://0.0.0.0:5000/" in the log output.
70 83
 
71 84
 .. code-block:: bash
72 85
 
73 86
     WEB_PORT=$(docker port $WEB_WORKER 5000)
74 87
 
75
-Look up the public-facing port which is NAT-ed. Find the private port used by the container and store it inside of the WEB_PORT variable.
88
+Look up the public-facing port which is NAT-ed. Find the private port
89
+used by the container and store it inside of the WEB_PORT variable.
76 90
 
77 91
 .. code-block:: bash
78 92
 
... ...
@@ -80,7 +97,8 @@ Look up the public-facing port which is NAT-ed. Find the private port used by th
80 80
     curl http://127.0.0.1:$WEB_PORT
81 81
       Hello world!
82 82
 
83
-Access the web app using curl. If everything worked as planned you should see the line "Hello world!" inside of your console.
83
+Access the web app using curl. If everything worked as planned you
84
+should see the line "Hello world!" inside of your console.
84 85
 
85 86
 **Video:**
86 87
 
... ...
@@ -7,16 +7,17 @@
7 7
 Running the Examples
8 8
 --------------------
9 9
 
10
-All the examples assume your machine is running the docker daemon. To run the docker daemon in the background, simply type:
10
+All the examples assume your machine is running the docker daemon. To
11
+run the docker daemon in the background, simply type:
11 12
 
12 13
    .. code-block:: bash
13 14
 
14 15
       sudo docker -d &
15 16
 
16
-Now you can run docker in client mode: all commands will be forwarded to the docker daemon, so the client
17
-can run from any account.
17
+Now you can run docker in client mode: by defalt all commands will be
18
+forwarded to the ``docker`` daemon via a protected Unix socket, so you
19
+must run as root.
18 20
 
19 21
    .. code-block:: bash
20 22
 
21
-      # now you can run docker commands from any account.
22
-      docker help
23
+      sudo docker help
... ...
@@ -16,12 +16,13 @@ Open a docker container
16 16
 
17 17
 .. code-block:: bash
18 18
 
19
-    docker run -i -t base /bin/bash
19
+    sudo docker run -i -t ubuntu /bin/bash
20 20
 
21 21
 Building your image
22 22
 -------------------
23 23
 
24
-Update your docker container, install the redis server.  Once installed, exit out of docker.
24
+Update your Docker container, install the Redis server.  Once
25
+installed, exit out of the Docker container.
25 26
 
26 27
 .. code-block:: bash
27 28
 
... ...
@@ -45,7 +46,7 @@ container running in the background. Use your snapshot.
45 45
 
46 46
 .. code-block:: bash
47 47
 
48
-    docker run -d -p 6379 <your username>/redis /usr/bin/redis-server
48
+    sudo docker run -d -p 6379 <your username>/redis /usr/bin/redis-server
49 49
 
50 50
 Test 1
51 51
 ++++++
... ...
@@ -54,8 +55,8 @@ Connect to the container with the redis-cli.
54 54
 
55 55
 .. code-block:: bash
56 56
 
57
-    docker ps  # grab the new container id
58
-    docker inspect <container_id>    # grab the ipaddress of the container
57
+    sudo docker ps  # grab the new container id
58
+    sudo docker inspect <container_id>    # grab the ipaddress of the container
59 59
     redis-cli -h <ipaddress> -p 6379
60 60
     redis 10.0.3.32:6379> set docker awesome
61 61
     OK
... ...
@@ -70,8 +71,8 @@ Connect to the host os with the redis-cli.
70 70
 
71 71
 .. code-block:: bash
72 72
 
73
-    docker ps  # grab the new container id
74
-    docker port <container_id> 6379  # grab the external port
73
+    sudo docker ps  # grab the new container id
74
+    sudo docker port <container_id> 6379  # grab the external port
75 75
     ip addr show   # grab the host ip address
76 76
     redis-cli -h <host ipaddress> -p <external port>
77 77
     redis 192.168.0.1:49153> set docker awesome
... ...
@@ -12,8 +12,16 @@ SSH Daemon Service
12 12
 
13 13
 **Video:**
14 14
 
15
-I've create a little screencast to show how to create a sshd service and connect to it. It is something like 11
16
-minutes and not entirely smooth, but gives you a good idea.
15
+I've create a little screencast to show how to create a sshd service
16
+and connect to it. It is something like 11 minutes and not entirely
17
+smooth, but gives you a good idea.
18
+
19
+.. note::
20
+   This screencast was created before ``docker`` version 0.5.2, so the
21
+   daemon is unprotected and available via a TCP port. When you run
22
+   through the same steps in a newer version of ``docker``, you will
23
+   need to add ``sudo`` in front of each ``docker`` command in order
24
+   to reach the daemon over its protected Unix socket.
17 25
 
18 26
 .. raw:: html
19 27
 
... ...
@@ -24,7 +32,7 @@ minutes and not entirely smooth, but gives you a good idea.
24 24
 You can also get this sshd container by using
25 25
 ::
26 26
 
27
-    docker pull dhrp/sshd
27
+    sudo docker pull dhrp/sshd
28 28
 
29 29
 
30 30
 The password is 'screencast'
... ...
@@ -90,7 +90,7 @@ Docker can now be installed on Amazon EC2 with a single vagrant command. Vagrant
90 90
 
91 91
    .. code-block:: bash
92 92
 
93
-      docker
93
+      sudo docker
94 94
 
95 95
 
96 96
 Continue with the :ref:`hello_world` example.
... ...
@@ -56,10 +56,10 @@ Run your first container!
56 56
 .. code-block:: bash
57 57
 
58 58
     # check your docker version
59
-    ./docker version
59
+    sudo ./docker version
60 60
 
61 61
     # run a container and open an interactive shell in the container
62
-    ./docker run -i -t ubuntu /bin/bash
62
+    sudo ./docker run -i -t ubuntu /bin/bash
63 63
 
64 64
 
65 65
 
... ...
@@ -76,7 +76,7 @@ Verify it worked
76 76
 .. code-block:: bash
77 77
 
78 78
    # download the base 'ubuntu' container and run bash inside it while setting up an interactive shell
79
-   docker run -i -t ubuntu /bin/bash
79
+   sudo docker run -i -t ubuntu /bin/bash
80 80
 
81 81
    # type 'exit' to exit
82 82
 
... ...
@@ -138,7 +138,7 @@ Verify it worked
138 138
 .. code-block:: bash
139 139
 
140 140
    # download the base 'ubuntu' container and run bash inside it while setting up an interactive shell
141
-   docker run -i -t ubuntu /bin/bash
141
+   sudo docker run -i -t ubuntu /bin/bash
142 142
 
143 143
    # type exit to exit
144 144
 
... ...
@@ -63,7 +63,7 @@ Now you are in the VM, run docker
63 63
 
64 64
 .. code-block:: bash
65 65
 
66
-   docker
66
+   sudo docker
67 67
 
68 68
 
69 69
 Continue with the :ref:`hello_world` example.
... ...
@@ -9,11 +9,13 @@ The Basics
9 9
 Starting Docker
10 10
 ---------------
11 11
 
12
-If you have used one of the quick install paths', Docker may have been installed with upstart, Ubuntu's
13
-system for starting processes at boot time. You should be able to run ``docker help`` and get output.
12
+If you have used one of the quick install paths', Docker may have been
13
+installed with upstart, Ubuntu's system for starting processes at boot
14
+time. You should be able to run ``sudo docker help`` and get output.
14 15
 
15
-If you get ``docker: command not found`` or something like ``/var/lib/docker/repositories: permission denied``
16
-you will need to specify the path to it and manually start it.
16
+If you get ``docker: command not found`` or something like
17
+``/var/lib/docker/repositories: permission denied`` you will need to
18
+specify the path to it and manually start it.
17 19
 
18 20
 .. code-block:: bash
19 21
 
... ...
@@ -27,45 +29,73 @@ Running an interactive shell
27 27
 .. code-block:: bash
28 28
 
29 29
   # Download an ubuntu image
30
-  docker pull ubuntu
30
+  sudo docker pull ubuntu
31 31
 
32 32
   # Run an interactive shell in the ubuntu image,
33 33
   # allocate a tty, attach stdin and stdout
34
-  docker run -i -t ubuntu /bin/bash
34
+  sudo docker run -i -t ubuntu /bin/bash
35 35
 
36
-Bind Docker to another host/port or a unix socket
36
+Why ``sudo``?
37
+-------------
38
+
39
+The ``docker`` daemon always runs as root, and since ``docker``
40
+version 0.5.2, ``docker`` binds to a Unix socket instead of a TCP
41
+port. By default that Unix socket is owned by the user *root*, and so,
42
+by default, you can access it with ``sudo``. 
43
+
44
+Starting in version 0.5.3, if you create a Unix group called *docker*
45
+and add users to it, then the ``docker`` daemon will make the
46
+ownership of the Unix socket read/writable by the *docker* group when
47
+the daemon starts. The ``docker`` daemon must always run as root, but
48
+if you run the ``docker`` client as a user in the *docker* group then
49
+you don't need to add ``sudo`` to all the client commands.
50
+
51
+Bind Docker to another host/port or a Unix socket
37 52
 -------------------------------------------------
38 53
 
39
-With -H it is possible to make the Docker daemon to listen on a specific ip and port. By default, it will listen on 127.0.0.1:4243 to allow only local connections but you can set it to 0.0.0.0:4243 or a specific host ip to give access to everybody.
54
+.. DANGER:: Changing the default ``docker`` daemon binding to a TCP
55
+   port or Unix *docker* user group will increase your security risks
56
+   by allowing non-root users to potentially gain *root* access on the
57
+   host (`e.g. #1369
58
+   <https://github.com/dotcloud/docker/issues/1369>`_). Make sure you
59
+   control access to ``docker``.
40 60
 
41
-Similarly, the Docker client can use -H to connect to a custom port.
61
+With -H it is possible to make the Docker daemon to listen on a
62
+specific ip and port. By default, it will listen on
63
+``unix:///var/run/docker.sock`` to allow only local connections by the
64
+*root* user.  You *could* set it to 0.0.0.0:4243 or a specific host ip to
65
+give access to everybody, but that is **not recommended** because then
66
+it is trivial for someone to gain root access to the host where the
67
+daemon is running.
68
+
69
+Similarly, the Docker client can use ``-H`` to connect to a custom port.
70
+
71
+``-H`` accepts host and port assignment in the following format:
72
+``tcp://[host][:port]`` or ``unix://path``
42 73
 
43
--H accepts host and port assignment in the following format: tcp://[host][:port] or unix://path
44 74
 For example:
45 75
 
46
-* tcp://host -> tcp connection on host:4243
47
-* tcp://host:port -> tcp connection on host:port
48
-* tcp://:port -> tcp connection on 127.0.0.1:port
49
-* unix://path/to/socket -> unix socket located at path/to/socket
76
+* ``tcp://host:4243`` -> tcp connection on host:4243
77
+* ``unix://path/to/socket`` -> unix socket located at ``path/to/socket``
50 78
 
51 79
 .. code-block:: bash
52 80
 
53 81
    # Run docker in daemon mode
54 82
    sudo <path to>/docker -H 0.0.0.0:5555 -d &
55 83
    # Download an ubuntu image
56
-   docker -H :5555 pull ubuntu
84
+   sudo docker -H :5555 pull ubuntu
57 85
 
58
-You can use multiple -H, for example, if you want to listen
59
-on both tcp and a unix socket
86
+You can use multiple ``-H``, for example, if you want to listen on
87
+both TCP and a Unix socket
60 88
 
61 89
 .. code-block:: bash
62 90
 
63 91
    # Run docker in daemon mode
64 92
    sudo <path to>/docker -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock -d &
65
-   # Download an ubuntu image
66
-   docker pull ubuntu
67
-   # OR
68
-   docker -H unix:///var/run/docker.sock pull ubuntu
93
+   # Download an ubuntu image, use default Unix socket
94
+   sudo docker pull ubuntu
95
+   # OR use the TCP port
96
+   sudo docker -H tcp://127.0.0.1:4243 pull ubuntu
69 97
 
70 98
 Starting a long-running worker process
71 99
 --------------------------------------
... ...
@@ -73,13 +103,13 @@ Starting a long-running worker process
73 73
 .. code-block:: bash
74 74
 
75 75
   # Start a very useful long-running process
76
-  JOB=$(docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")
76
+  JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")
77 77
 
78 78
   # Collect the output of the job so far
79
-  docker logs $JOB
79
+  sudo docker logs $JOB
80 80
 
81 81
   # Kill the job
82
-  docker kill $JOB
82
+  sudo docker kill $JOB
83 83
 
84 84
 
85 85
 Listing all running containers
... ...
@@ -87,7 +117,7 @@ Listing all running containers
87 87
 
88 88
 .. code-block:: bash
89 89
 
90
-  docker ps
90
+  sudo docker ps
91 91
 
92 92
 Expose a service on a TCP port
93 93
 ------------------------------
... ...
@@ -95,10 +125,10 @@ Expose a service on a TCP port
95 95
 .. code-block:: bash
96 96
 
97 97
   # Expose port 4444 of this container, and tell netcat to listen on it
98
-  JOB=$(docker run -d -p 4444 ubuntu /bin/nc -l -p 4444)
98
+  JOB=$(sudo docker run -d -p 4444 ubuntu /bin/nc -l -p 4444)
99 99
 
100 100
   # Which public port is NATed to my container?
101
-  PORT=$(docker port $JOB 4444)
101
+  PORT=$(sudo docker port $JOB 4444)
102 102
 
103 103
   # Connect to the public port via the host's public address
104 104
   # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
... ...
@@ -107,7 +137,7 @@ Expose a service on a TCP port
107 107
   echo hello world | nc $IP $PORT
108 108
 
109 109
   # Verify that the network connection worked
110
-  echo "Daemon received: $(docker logs $JOB)"
110
+  echo "Daemon received: $(sudo docker logs $JOB)"
111 111
 
112 112
 
113 113
 Committing (saving) a container state
... ...
@@ -115,21 +145,23 @@ Committing (saving) a container state
115 115
 
116 116
 Save your containers state to a container image, so the state can be re-used.
117 117
 
118
-When you commit your container only the differences between the image the container was created from
119
-and the current state of the container will be stored (as a diff). See which images you already have
120
-using ``docker images``
118
+When you commit your container only the differences between the image
119
+the container was created from and the current state of the container
120
+will be stored (as a diff). See which images you already have using
121
+``sudo docker images``
121 122
 
122 123
 .. code-block:: bash
123 124
 
124 125
     # Commit your container to a new named image
125
-    docker commit <container_id> <some_name>
126
+    sudo docker commit <container_id> <some_name>
126 127
 
127 128
     # List your containers
128
-    docker images
129
+    sudo docker images
129 130
 
130 131
 You now have a image state from which you can create new instances.
131 132
 
132 133
 
133 134
 
134
-Read more about :ref:`working_with_the_repository` or continue to the complete :ref:`cli`
135
+Read more about :ref:`working_with_the_repository` or continue to the
136
+complete :ref:`cli`
135 137
 
... ...
@@ -25,12 +25,12 @@ describe the steps to assemble the image.
25 25
 Then call ``docker build`` with the path of your source repository as
26 26
 argument:
27 27
 
28
-    ``docker build .``
28
+    ``sudo docker build .``
29 29
 
30 30
 You can specify a repository and tag at which to save the new image if the
31 31
 build succeeds:
32 32
 
33
-    ``docker build -t shykes/myapp .``
33
+    ``sudo docker build -t shykes/myapp .``
34 34
 
35 35
 Docker will run your steps one-by-one, committing the result if necessary,
36 36
 before finally outputting the ID of your new image.
... ...
@@ -6,20 +6,23 @@
6 6
 Port redirection
7 7
 ================
8 8
 
9
-Docker can redirect public tcp ports to your container, so it can be reached over the network.
10
-Port redirection is done on ``docker run`` using the -p flag.
9
+Docker can redirect public TCP ports to your container, so it can be
10
+reached over the network.  Port redirection is done on ``docker run``
11
+using the -p flag.
11 12
 
12
-A port redirect is specified as PUBLIC:PRIVATE, where tcp port PUBLIC will be redirected to
13
-tcp port PRIVATE. As a special case, the public port can be omitted, in which case a random
14
-public port will be allocated.
13
+A port redirect is specified as *PUBLIC:PRIVATE*, where TCP port
14
+*PUBLIC* will be redirected to TCP port *PRIVATE*. As a special case,
15
+the public port can be omitted, in which case a random public port
16
+will be allocated.
15 17
 
16 18
 .. code-block:: bash
17 19
 
18 20
     # A random PUBLIC port is redirected to PRIVATE port 80 on the container
19
-    docker run -p 80 <image> <cmd>
21
+    sudo docker run -p 80 <image> <cmd>
20 22
 
21 23
     # PUBLIC port 80 is redirected to PRIVATE port 80
22
-    docker run -p 80:80 <image> <cmd>
24
+    sudo docker run -p 80:80 <image> <cmd>
23 25
 
24 26
 
25
-Default port redirects can be built into a container with the EXPOSE build command.
27
+Default port redirects can be built into a container with the
28
+``EXPOSE`` build command.
... ...
@@ -9,28 +9,32 @@ Using Puppet
9 9
 
10 10
 .. note::
11 11
 
12
-   Please note this is a community contributed installation path. The only 'official' installation is using the
13
-   :ref:`ubuntu_linux` installation path. This version may sometimes be out of date.
12
+   Please note this is a community contributed installation path. The
13
+   only 'official' installation is using the :ref:`ubuntu_linux`
14
+   installation path. This version may sometimes be out of date.
14 15
 
15 16
 Requirements
16 17
 ------------
17 18
 
18
-To use this guide you'll need a working installation of Puppet from `Puppetlabs <https://www.puppetlabs.com>`_ .
19
+To use this guide you'll need a working installation of Puppet from
20
+`Puppetlabs <https://www.puppetlabs.com>`_ .
19 21
 
20 22
 The module also currently uses the official PPA so only works with Ubuntu.
21 23
 
22 24
 Installation
23 25
 ------------
24 26
 
25
-The module is available on the `Puppet Forge <https://forge.puppetlabs.com/garethr/docker/>`_
26
-and can be installed using the built-in module tool.
27
+The module is available on the `Puppet Forge
28
+<https://forge.puppetlabs.com/garethr/docker/>`_ and can be installed
29
+using the built-in module tool.
27 30
 
28 31
 .. code-block:: bash
29 32
 
30 33
    puppet module install garethr/docker
31 34
 
32
-It can also be found on `GitHub <https://www.github.com/garethr/garethr-docker>`_ 
33
-if you would rather download the source.
35
+It can also be found on `GitHub
36
+<https://www.github.com/garethr/garethr-docker>`_ if you would rather
37
+download the source.
34 38
 
35 39
 Usage
36 40
 -----
... ...
@@ -57,10 +57,10 @@ address of the registry's host, like this:
57 57
     # Tag to create a repository with the full registry location.
58 58
     # The location (e.g. localhost.localdomain:5000) becomes
59 59
     # a permanent part of the repository name
60
-    docker tag 0u812deadbeef localhost.localdomain:5000/repo_name
60
+    sudo docker tag 0u812deadbeef localhost.localdomain:5000/repo_name
61 61
 
62 62
     # Push the new repository to its home location on localhost
63
-    docker push localhost.localdomain:5000/repo_name
63
+    sudo docker push localhost.localdomain:5000/repo_name
64 64
 
65 65
 Once a repository has your registry's host name as part of the tag,
66 66
 you can push and pull it like any other repository, but it will
... ...
@@ -75,14 +75,14 @@ Search by name, namespace or description
75 75
 
76 76
 .. code-block:: bash
77 77
 
78
-    docker search <value>
78
+    sudo docker search <value>
79 79
 
80 80
 
81 81
 Download them simply by their name
82 82
 
83 83
 .. code-block:: bash
84 84
 
85
-    docker pull <value>
85
+    sudo docker pull <value>
86 86
 
87 87
 
88 88
 Very similarly you can search for and browse the index online on
... ...
@@ -96,7 +96,7 @@ You can create a user on the central Docker Index online, or by running
96 96
 
97 97
 .. code-block:: bash
98 98
 
99
-    docker login
99
+    sudo docker login
100 100
 
101 101
 This will prompt you for a username, which will become a public
102 102
 namespace for your public repositories.
... ...
@@ -115,7 +115,7 @@ your container to an image within your username namespace.
115 115
 .. code-block:: bash
116 116
 
117 117
     # for example docker commit $CONTAINER_ID dhrp/kickassapp
118
-    docker commit <container_id> <username>/<repo_name>
118
+    sudo docker commit <container_id> <username>/<repo_name>
119 119
 
120 120
 
121 121
 Pushing a container to its repository
... ...
@@ -129,4 +129,4 @@ Now you can commit this image to the repository
129 129
 .. code-block:: bash
130 130
 
131 131
     # for example docker push dhrp/kickassapp
132
-    docker push <username>/<repo_name>
132
+    sudo docker push <username>/<repo_name>