| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,91 @@ |
| 0 |
+============== |
|
| 1 |
+Docker Builder |
|
| 2 |
+============== |
|
| 3 |
+ |
|
| 4 |
+.. contents:: Table of Contents |
|
| 5 |
+ |
|
| 6 |
+1. Format |
|
| 7 |
+========= |
|
| 8 |
+ |
|
| 9 |
+The Docker builder format is quite simple: |
|
| 10 |
+ |
|
| 11 |
+ ``instruction arguments`` |
|
| 12 |
+ |
|
| 13 |
+The first instruction must be `FROM` |
|
| 14 |
+ |
|
| 15 |
+All instruction are to be placed in a file named `Dockerfile` |
|
| 16 |
+ |
|
| 17 |
+In order to place comments within a Dockerfile, simply prefix the line with "`#`" |
|
| 18 |
+ |
|
| 19 |
+2. Instructions |
|
| 20 |
+=============== |
|
| 21 |
+ |
|
| 22 |
+Docker builder comes with a set of instructions: |
|
| 23 |
+ |
|
| 24 |
+1. FROM: Set from what image to build |
|
| 25 |
+2. RUN: Execute a command |
|
| 26 |
+3. INSERT: Insert a remote file (http) into the image |
|
| 27 |
+ |
|
| 28 |
+2.1 FROM |
|
| 29 |
+-------- |
|
| 30 |
+ ``FROM <image>`` |
|
| 31 |
+ |
|
| 32 |
+The `FROM` instruction must be the first one in order for Builder to know from where to run commands. |
|
| 33 |
+ |
|
| 34 |
+`FROM` can also be used in order to build multiple images within a single Dockerfile |
|
| 35 |
+ |
|
| 36 |
+2.2 RUN |
|
| 37 |
+------- |
|
| 38 |
+ ``RUN <command>`` |
|
| 39 |
+ |
|
| 40 |
+The `RUN` instruction is the main one, it allows you to execute any commands on the `FROM` image and to save the results. |
|
| 41 |
+You can use as many `RUN` as you want within a Dockerfile, the commands will be executed on the result of the previous command. |
|
| 42 |
+ |
|
| 43 |
+2.3 INSERT |
|
| 44 |
+---------- |
|
| 45 |
+ |
|
| 46 |
+ ``INSERT <file url> <path>`` |
|
| 47 |
+ |
|
| 48 |
+The `INSERT` instruction will download the file at the given url and place it within the image at the given path. |
|
| 49 |
+ |
|
| 50 |
+.. note:: |
|
| 51 |
+ The path must include the file name. |
|
| 52 |
+ |
|
| 53 |
+3. Dockerfile Examples |
|
| 54 |
+====================== |
|
| 55 |
+ |
|
| 56 |
+:: |
|
| 57 |
+ |
|
| 58 |
+ # Nginx |
|
| 59 |
+ # |
|
| 60 |
+ # VERSION 0.0.1 |
|
| 61 |
+ # DOCKER-VERSION 0.2 |
|
| 62 |
+ |
|
| 63 |
+ from ubuntu |
|
| 64 |
+ |
|
| 65 |
+ # make sure the package repository is up to date |
|
| 66 |
+ run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list |
|
| 67 |
+ run apt-get update |
|
| 68 |
+ |
|
| 69 |
+ run apt-get install -y inotify-tools nginx apache openssh-server |
|
| 70 |
+ insert https://raw.github.com/creack/docker-vps/master/nginx-wrapper.sh /usr/sbin/nginx-wrapper |
|
| 71 |
+ |
|
| 72 |
+:: |
|
| 73 |
+ |
|
| 74 |
+ # Firefox over VNC |
|
| 75 |
+ # |
|
| 76 |
+ # VERSION 0.3 |
|
| 77 |
+ # DOCKER-VERSION 0.2 |
|
| 78 |
+ |
|
| 79 |
+ from ubuntu |
|
| 80 |
+ # make sure the package repository is up to date |
|
| 81 |
+ run echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list |
|
| 82 |
+ run apt-get update |
|
| 83 |
+ |
|
| 84 |
+ # Install vnc, xvfb in order to create a 'fake' display and firefox |
|
| 85 |
+ run apt-get install -y x11vnc xvfb firefox |
|
| 86 |
+ run mkdir /.vnc |
|
| 87 |
+ # Setup a password |
|
| 88 |
+ run x11vnc -storepasswd 1234 ~/.vnc/passwd |
|
| 89 |
+ # Autostart firefox (might not be the best way to do it, but it does the trick) |
|
| 90 |
+ run bash -c 'echo "firefox" >> /.bashrc' |
| 33 | 34 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,9 @@ |
| 0 |
+=========================================== |
|
| 1 |
+``build`` -- Build a container from Dockerfile via stdin |
|
| 2 |
+=========================================== |
|
| 3 |
+ |
|
| 4 |
+:: |
|
| 5 |
+ |
|
| 6 |
+ Usage: docker build - |
|
| 7 |
+ Example: cat Dockerfile | docker build - |
|
| 8 |
+ Build a new image from the Dockerfile passed via stdin |
| ... | ... |
@@ -15,7 +15,8 @@ This documentation has the following resources: |
| 15 | 15 |
examples/index |
| 16 | 16 |
contributing/index |
| 17 | 17 |
commandline/index |
| 18 |
+ builder/index |
|
| 18 | 19 |
faq |
| 19 | 20 |
|
| 20 | 21 |
|
| 21 |
-.. image:: http://www.docker.io/_static/lego_docker.jpg |
|
| 22 | 22 |
\ No newline at end of file |
| 23 |
+.. image:: http://www.docker.io/_static/lego_docker.jpg |