Browse code

A variety of syntax and style fixes for the Docker examples

* Made Docker a proper noun when needed.
* Fixed code syntax
* Fixed some whitespace issues
* Fixed some typos and grammar
* Tidied up some examples

James Turnbull authored on 2013/11/03 10:26:52
Showing 10 changed files
... ...
@@ -10,7 +10,7 @@ CouchDB Service
10 10
 .. include:: example_header.inc
11 11
 
12 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
13
+two CouchDB containers.  This could be used for hot upgrades, testing
14 14
 different versions of CouchDB on the same data, etc.
15 15
 
16 16
 Create first database
... ...
@@ -25,8 +25,8 @@ Note that we're marking ``/var/lib/couchdb`` as a data volume.
25 25
 Add data to the first database
26 26
 ------------------------------
27 27
 
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
+We're assuming your Docker host is reachable at ``localhost``. If not,
29
+replace ``localhost`` with the public IP of your Docker host.
30 30
 
31 31
 .. code-block:: bash
32 32
 
... ...
@@ -37,7 +37,7 @@ replace `localhost` with the public IP of your docker host.
37 37
 Create second database
38 38
 ----------------------
39 39
 
40
-This time, we're requesting shared access to $COUCH1's volumes.
40
+This time, we're requesting shared access to ``$COUCH1``'s volumes.
41 41
 
42 42
 .. code-block:: bash
43 43
 
... ...
@@ -52,5 +52,5 @@ Browse data on the second database
52 52
     URL="http://$HOST:$(sudo docker port $COUCH2 5984)/_utils/"
53 53
     echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!'
54 54
 
55
-Congratulations, you are running 2 Couchdb containers, completely
55
+Congratulations, you are now running two Couchdb containers, completely
56 56
 isolated from each other *except* for their data.
... ...
@@ -12,16 +12,16 @@ Hello World
12 12
 Running the Examples
13 13
 ====================
14 14
 
15
-All the examples assume your machine is running the docker daemon. To
16
-run the docker daemon in the background, simply type:
15
+All the examples assume your machine is running the ``docker`` daemon. To
16
+run the ``docker`` daemon in the background, simply type:
17 17
 
18 18
 .. code-block:: bash
19 19
 
20 20
    sudo docker -d &
21 21
 
22
-Now you can run docker in client mode: by default all commands will be
22
+Now you can run Docker in client mode: by default all commands will be
23 23
 forwarded to the ``docker`` daemon via a protected Unix socket, so you
24
-must run as root.
24
+must run as the ``root`` or via the ``sudo`` command.
25 25
 
26 26
 .. code-block:: bash
27 27
 
... ...
@@ -38,23 +38,24 @@ Hello World
38 38
 
39 39
 This is the most basic example available for using Docker.
40 40
 
41
-Download the base image (named "ubuntu"):
41
+Download the base image which is named ``ubuntu``:
42 42
 
43 43
 .. code-block:: bash
44 44
 
45 45
     # Download an ubuntu image
46 46
     sudo docker pull ubuntu
47 47
 
48
-Alternatively to the *ubuntu* image, you can select *busybox*, a bare
48
+Alternatively to the ``ubuntu`` image, you can select ``busybox``, a bare
49 49
 minimal Linux system. The images are retrieved from the Docker
50 50
 repository.
51 51
 
52 52
 
53 53
 .. code-block:: bash
54 54
 
55
-    #run a simple echo command, that will echo hello world back to the console over standard out.
56 55
     sudo docker run ubuntu /bin/echo hello world
57 56
 
57
+This command will run a simple ``echo`` command, that will echo ``hello world`` back to the console over standard out.
58
+
58 59
 **Explanation:**
59 60
 
60 61
 - **"sudo"** execute the following commands as user *root* 
... ...
@@ -100,9 +101,9 @@ we stop it.
100 100
     CONTAINER_ID=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done")
101 101
 
102 102
 We are going to run a simple hello world daemon in a new container
103
-made from the *ubuntu* image.
103
+made from the ``ubuntu`` image.
104 104
 
105
-- **"docker run -d "** run a command in a new container. We pass "-d"
105
+- **"sudo docker run -d "** run a command in a new container. We pass "-d"
106 106
   so it runs as a daemon.
107 107
 - **"ubuntu"** is the image we want to run the command inside of.
108 108
 - **"/bin/sh -c"** is the command we want to run in the container
... ...
@@ -10,7 +10,7 @@ Examples
10 10
 
11 11
 Here are some examples of how to use Docker to create running
12 12
 processes, starting from a very simple *Hello World* and progressing
13
-to more substantial services like you might find in production.
13
+to more substantial services like those which you might find in production.
14 14
 
15 15
 .. toctree::
16 16
    :maxdepth: 1
... ...
@@ -10,8 +10,8 @@ Building an Image with MongoDB
10 10
 .. include:: example_header.inc
11 11
 
12 12
 The goal of this example is to show how you can build your own
13
-docker images with MongoDB preinstalled. We will do that by
14
-constructing a Dockerfile that downloads a base image, adds an
13
+Docker images with MongoDB pre-installed. We will do that by
14
+constructing a ``Dockerfile`` that downloads a base image, adds an
15 15
 apt source and installs the database software on Ubuntu.
16 16
 
17 17
 Creating a ``Dockerfile``
... ...
@@ -41,7 +41,7 @@ Since we want to be running the latest version of MongoDB we'll need to add the
41 41
     RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list
42 42
 
43 43
 Then, we don't want Ubuntu to complain about init not being available so we'll
44
-divert /sbin/initctl to /bin/true so it thinks everything is working.
44
+divert ``/sbin/initctl`` to ``/bin/true`` so it thinks everything is working.
45 45
 
46 46
 .. code-block:: bash
47 47
 
... ...
@@ -65,8 +65,8 @@ run without needing to provide a special configuration file)
65 65
     # Create the MongoDB data directory
66 66
     RUN mkdir -p /data/db
67 67
 
68
-Finally, we'll expose the standard port that MongoDB runs on (27107) as well as
69
-define an ENTRYPOINT for the container.
68
+Finally, we'll expose the standard port that MongoDB runs on, 27107, as well as
69
+define an ``ENTRYPOINT`` instruction for the container.
70 70
 
71 71
 .. code-block:: bash
72 72
 
... ...
@@ -78,7 +78,7 @@ run all of the commands.
78 78
 
79 79
 .. code-block:: bash
80 80
 
81
-    docker build -t <yourname>/mongodb .
81
+    sudo docker build -t <yourname>/mongodb .
82 82
 
83 83
 Now you should be able to run ``mongod`` as a daemon and be able to connect on
84 84
 the local port!
... ...
@@ -86,13 +86,13 @@ the local port!
86 86
 .. code-block:: bash
87 87
 
88 88
     # Regular style
89
-    MONGO_ID=$(docker run -d <yourname>/mongodb)
89
+    MONGO_ID=$(sudo docker run -d <yourname>/mongodb)
90 90
 
91 91
     # Lean and mean
92
-    MONGO_ID=$(docker run -d <yourname>/mongodb --noprealloc --smallfiles)
92
+    MONGO_ID=$(sudo docker run -d <yourname>/mongodb --noprealloc --smallfiles)
93 93
 
94 94
     # Check the logs out
95
-    docker logs $MONGO_ID
95
+    sudo docker logs $MONGO_ID
96 96
 
97 97
     # Connect and play around
98 98
     mongo --port <port you get from `docker ps`>
... ...
@@ -10,7 +10,7 @@ Node.js Web App
10 10
 .. include:: example_header.inc
11 11
 
12 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
13
+Docker images from a parent image using a ``Dockerfile`` . We will do
14 14
 that by making a simple Node.js hello world web application running on
15 15
 CentOS. You can get the full source code at
16 16
 https://github.com/gasi/docker-node-hello.
... ...
@@ -55,7 +55,7 @@ Then, create an ``index.js`` file that defines a web app using the
55 55
 
56 56
 
57 57
 In the next steps, we’ll look at how you can run this app inside a CentOS
58
-container using docker. First, you’ll need to build a docker image of your app.
58
+container using Docker. First, you’ll need to build a Docker image of your app.
59 59
 
60 60
 Creating a ``Dockerfile``
61 61
 +++++++++++++++++++++++++
... ...
@@ -67,8 +67,8 @@ Create an empty file called ``Dockerfile``:
67 67
     touch Dockerfile
68 68
 
69 69
 Open the ``Dockerfile`` in your favorite text editor and add the following line
70
-that defines the version of docker the image requires to build
71
-(this example uses docker 0.3.4):
70
+that defines the version of Docker the image requires to build
71
+(this example uses Docker 0.3.4):
72 72
 
73 73
 .. code-block:: bash
74 74
 
... ...
@@ -76,7 +76,7 @@ that defines the version of docker the image requires to build
76 76
 
77 77
 Next, define the parent image you want to use to build your own image on top of.
78 78
 Here, we’ll use `CentOS <https://index.docker.io/_/centos/>`_ (tag: ``6.4``)
79
-available on the `docker index`_:
79
+available on the `Docker index`_:
80 80
 
81 81
 .. code-block:: bash
82 82
 
... ...
@@ -95,23 +95,23 @@ To install the right package for CentOS, we’ll use the instructions from the
95 95
     # Install Node.js and npm
96 96
     RUN     yum install -y npm
97 97
 
98
-To bundle your app’s source code inside the docker image, use the ``ADD``
99
-command:
98
+To bundle your app’s source code inside the Docker image, use the ``ADD``
99
+instruction:
100 100
 
101 101
 .. code-block:: bash
102 102
 
103 103
     # Bundle app source
104 104
     ADD . /src
105 105
 
106
-Install your app dependencies using npm:
106
+Install your app dependencies using the ``npm`` binary:
107 107
 
108 108
 .. code-block:: bash
109 109
 
110 110
     # Install app dependencies
111 111
     RUN cd /src; npm install
112 112
 
113
-Your app binds to port ``8080`` so you’ll use the ``EXPOSE`` command
114
-to have it mapped by the docker daemon:
113
+Your app binds to port ``8080`` so you’ll use the ``EXPOSE`` instruction
114
+to have it mapped by the ``docker`` daemon:
115 115
 
116 116
 .. code-block:: bash
117 117
 
... ...
@@ -152,7 +152,7 @@ Building your image
152 152
 +++++++++++++++++++
153 153
 
154 154
 Go to the directory that has your ``Dockerfile`` and run the following
155
-command to build a docker image. The ``-t`` flag let’s you tag your
155
+command to build a Docker image. The ``-t`` flag let’s you tag your
156 156
 image so it’s easier to find later using the ``docker images``
157 157
 command:
158 158
 
... ...
@@ -160,7 +160,7 @@ command:
160 160
 
161 161
     sudo docker build -t <your username>/centos-node-hello .
162 162
 
163
-Your image will now be listed by docker:
163
+Your image will now be listed by Docker:
164 164
 
165 165
 .. code-block:: bash
166 166
 
... ...
@@ -199,17 +199,17 @@ Print the output of your app:
199 199
 Test
200 200
 ++++
201 201
 
202
-To test your app, get the the port of your app that docker mapped:
202
+To test your app, get the the port of your app that Docker mapped:
203 203
 
204 204
 .. code-block:: bash
205 205
 
206
-    docker ps
206
+    sudo docker ps
207 207
 
208 208
     > # Example
209 209
     > ID            IMAGE                          COMMAND              ...   PORTS
210 210
     > ecce33b30ebf  gasi/centos-node-hello:latest  node /src/index.js         49160->8080
211 211
 
212
-In the example above, docker mapped the ``8080`` port of the container to
212
+In the example above, Docker mapped the ``8080`` port of the container to
213 213
 ``49160``.
214 214
 
215 215
 Now you can call your app using ``curl`` (install if needed via:
... ...
@@ -229,7 +229,7 @@ Now you can call your app using ``curl`` (install if needed via:
229 229
     > Hello World
230 230
 
231 231
 We hope this tutorial helped you get up and running with Node.js and
232
-CentOS on docker. You can get the full source code at
232
+CentOS on Docker. You can get the full source code at
233 233
 https://github.com/gasi/docker-node-hello.
234 234
 
235 235
 Continue to :ref:`running_redis_service`.
... ...
@@ -13,7 +13,7 @@ PostgreSQL Service
13 13
 
14 14
 .. note::
15 15
 
16
-    As of version 0.5.2, docker requires root privileges to run.
16
+    As of version 0.5.2, Docker requires root privileges to run.
17 17
     You have to either manually adjust your system configuration (permissions on
18 18
     /var/run/docker.sock or sudo config), or prefix `docker` with `sudo`. Check
19 19
     `this thread`_ for details.
... ...
@@ -24,8 +24,7 @@ PostgreSQL Service
24 24
 Installing PostgreSQL on Docker
25 25
 -------------------------------
26 26
 
27
-For clarity I won't be showing commands output.
28
-
27
+For clarity I won't be showing command output.
29 28
 
30 29
 Run an interactive shell in Docker container.
31 30
 
... ...
@@ -62,7 +61,7 @@ Finally, install PostgreSQL 9.2
62 62
 
63 63
 Now, create a PostgreSQL superuser role that can create databases and
64 64
 other roles.  Following Vagrant's convention the role will be named
65
-`docker` with `docker` password assigned to it.
65
+``docker`` with ``docker`` password assigned to it.
66 66
 
67 67
 .. code-block:: bash
68 68
 
... ...
@@ -108,7 +107,7 @@ Bash prompt; you can also locate it using ``docker ps -a``.
108 108
 
109 109
 .. code-block:: bash
110 110
 
111
-    docker commit <container_id> <your username>/postgresql
111
+    sudo docker commit <container_id> <your username>/postgresql
112 112
 
113 113
 Finally, run PostgreSQL server via ``docker``.
114 114
 
... ...
@@ -10,9 +10,9 @@ Python Web App
10 10
 .. include:: example_header.inc
11 11
 
12 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
13
+Docker images using a parent image, making changes to it, and then
14 14
 saving the results as a new image. We will do that by making a simple
15
-hello flask web application image.
15
+hello Flask web application image.
16 16
 
17 17
 **Steps:**
18 18
 
... ...
@@ -20,22 +20,22 @@ hello flask web application image.
20 20
 
21 21
     sudo docker pull shykes/pybuilder
22 22
 
23
-We are downloading the "shykes/pybuilder" docker image
23
+We are downloading the ``shykes/pybuilder`` Docker image
24 24
 
25 25
 .. code-block:: bash
26 26
 
27 27
     URL=http://github.com/shykes/helloflask/archive/master.tar.gz
28 28
 
29
-We set a URL variable that points to a tarball of a simple helloflask web app
29
+We set a ``URL`` variable that points to a tarball of a simple helloflask web app
30 30
 
31 31
 .. code-block:: bash
32 32
 
33 33
     BUILD_JOB=$(sudo docker run -d -t shykes/pybuilder:latest /usr/local/bin/buildapp $URL)
34 34
 
35
-Inside of the "shykes/pybuilder" image there is a command called
36
-buildapp, we are running that command and passing the $URL variable
35
+Inside of the ``shykes/pybuilder`` image there is a command called
36
+``buildapp``, we are running that command and passing the ``$URL`` variable
37 37
 from step 2 to it, and running the whole thing inside of a new
38
-container. BUILD_JOB will be set with the new container_id.
38
+container. The ``BUILD_JOB`` environment variable will be set with the new container ID.
39 39
 
40 40
 .. code-block:: bash
41 41
 
... ...
@@ -43,13 +43,13 @@ container. BUILD_JOB will be set with the new container_id.
43 43
     [...]
44 44
 
45 45
 While this container is running, we can attach to the new container to
46
-see what is going on. Ctrl-C to disconnect.
46
+see what is going on. You can use Ctrl-C to disconnect.
47 47
 
48 48
 .. code-block:: bash
49 49
 
50 50
     sudo docker ps -a
51
-    
52
-List all docker containers. If this container has already finished
51
+
52
+List all Docker containers. If this container has already finished
53 53
 running, it will still be listed here.
54 54
 
55 55
 .. code-block:: bash
... ...
@@ -57,8 +57,8 @@ running, it will still be listed here.
57 57
     BUILD_IMG=$(sudo docker commit $BUILD_JOB _/builds/github.com/shykes/helloflask/master)
58 58
 
59 59
 Save the changes we just made in the container to a new image called
60
-``_/builds/github.com/hykes/helloflask/master`` and save the image id in
61
-the BUILD_IMG variable name.
60
+``_/builds/github.com/hykes/helloflask/master`` and save the image ID in
61
+the ``BUILD_IMG`` variable name.
62 62
 
63 63
 .. code-block:: bash
64 64
 
... ...
@@ -72,24 +72,24 @@ the BUILD_IMG variable name.
72 72
 - **/usr/local/bin/runapp** is the command which starts the web app.
73 73
 
74 74
 Use the new image we just created and create a new container with
75
-network port 5000, and return the container id and store in the
76
-WEB_WORKER variable.
75
+network port 5000, and return the container ID and store in the
76
+``WEB_WORKER`` variable.
77 77
 
78 78
 .. code-block:: bash
79 79
 
80 80
     sudo docker logs $WEB_WORKER
81 81
      * Running on http://0.0.0.0:5000/
82 82
 
83
-View the logs for the new container using the WEB_WORKER variable, and
84
-if everything worked as planned you should see the line "Running on
85
-http://0.0.0.0:5000/" in the log output.
83
+View the logs for the new container using the ``WEB_WORKER`` variable, and
84
+if everything worked as planned you should see the line ``Running on
85
+http://0.0.0.0:5000/`` in the log output.
86 86
 
87 87
 .. code-block:: bash
88 88
 
89 89
     WEB_PORT=$(sudo docker port $WEB_WORKER 5000)
90 90
 
91 91
 Look up the public-facing port which is NAT-ed. Find the private port
92
-used by the container and store it inside of the WEB_PORT variable.
92
+used by the container and store it inside of the ``WEB_PORT`` variable.
93 93
 
94 94
 .. code-block:: bash
95 95
 
... ...
@@ -97,8 +97,8 @@ used by the container and store it inside of the WEB_PORT variable.
97 97
     curl http://127.0.0.1:$WEB_PORT
98 98
       Hello world!
99 99
 
100
-Access the web app using curl. If everything worked as planned you
101
-should see the line "Hello world!" inside of your console.
100
+Access the web app using the ``curl`` binary. If everything worked as planned you
101
+should see the line ``Hello world!`` inside of your console.
102 102
 
103 103
 **Video:**
104 104
 
... ...
@@ -9,7 +9,7 @@ Redis Service
9 9
 
10 10
 .. include:: example_header.inc
11 11
 
12
-Very simple, no frills, redis service.
12
+Very simple, no frills, Redis service.
13 13
 
14 14
 Open a docker container
15 15
 -----------------------
... ...
@@ -35,13 +35,13 @@ Snapshot the installation
35 35
 
36 36
 .. code-block:: bash
37 37
 
38
-    docker ps -a  # grab the container id (this will be the first one in the list)
39
-    docker commit <container_id> <your username>/redis
38
+    sudo docker ps -a  # grab the container id (this will be the first one in the list)
39
+    sudo docker commit <container_id> <your username>/redis
40 40
 
41 41
 Run the service
42 42
 ---------------
43 43
 
44
-Running the service with `-d` runs the container in detached mode, leaving the
44
+Running the service with ``-d`` runs the container in detached mode, leaving the
45 45
 container running in the background. Use your snapshot.
46 46
 
47 47
 .. code-block:: bash
... ...
@@ -51,7 +51,7 @@ container running in the background. Use your snapshot.
51 51
 Test 1
52 52
 ++++++
53 53
 
54
-Connect to the container with the redis-cli.
54
+Connect to the container with the ``redis-cli`` binary.
55 55
 
56 56
 .. code-block:: bash
57 57
 
... ...
@@ -67,7 +67,7 @@ Connect to the container with the redis-cli.
67 67
 Test 2
68 68
 ++++++
69 69
 
70
-Connect to the host os with the redis-cli.
70
+Connect to the host os with the ``redis-cli`` binary.
71 71
 
72 72
 .. code-block:: bash
73 73
 
... ...
@@ -107,7 +107,7 @@ Create a ``supervisord`` configuration file
107 107
 +++++++++++++++++++++++++++++++++++++++++++
108 108
 
109 109
 Create an empty file called ``supervisord.conf``. Make sure it's at the same
110
-level as your ``Dockerfile``:
110
+directory level as your ``Dockerfile``:
111 111
 
112 112
 .. code-block:: bash
113 113
 
... ...
@@ -12,14 +12,14 @@ 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
15
+I've create a little screencast to show how to create a SSHd service
16 16
 and connect to it. It is something like 11 minutes and not entirely
17 17
 smooth, but gives you a good idea.
18 18
 
19 19
 .. note::
20
-   This screencast was created before ``docker`` version 0.5.2, so the
20
+   This screencast was created before Docker version 0.5.2, so the
21 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
22
+   through the same steps in a newer version of Docker, you will
23 23
    need to add ``sudo`` in front of each ``docker`` command in order
24 24
    to reach the daemon over its protected Unix socket.
25 25
 
... ...
@@ -29,13 +29,14 @@ smooth, but gives you a good idea.
29 29
       <iframe width="800" height="400" src="http://ascii.io/a/2637/raw" frameborder="0"></iframe>
30 30
     </div>
31 31
         
32
-You can also get this sshd container by using
33
-::
32
+You can also get this sshd container by using:
33
+
34
+.. code-block:: bash
34 35
 
35 36
     sudo docker pull dhrp/sshd
36 37
 
37 38
 
38
-The password is 'screencast'
39
+The password is ``screencast``.
39 40
 
40 41
 **Video's Transcription:**
41 42