@@ -49,13 +49,18 @@ to any of the files in the context. For example, your build can use an
4949[ * ADD* ] ( ../builder.md#add ) instruction to reference a file in the
5050context.
5151
52- The ` URL ` parameter can specify the location of a Git repository; the repository
53- acts as the build context. The system recursively clones the repository and its
54- submodules using a ` git clone --depth 1 --recursive ` command. This command runs
55- in a temporary directory on your local host. After the command succeeds, the
56- directory is sent to the Docker daemon as the context. Local clones give you the
57- ability to access private repositories using local user credentials, VPNs, and
58- so forth.
52+ The ` URL ` parameter can refer to three kinds of resources: Git repositories,
53+ pre-packaged tarball contexts and plain text files.
54+
55+ ### Git repositories
56+
57+ When the ` URL ` parameter points to the location of a Git repository, the
58+ repository acts as the build context. The system recursively clones the
59+ repository and its submodules using a ` git clone --depth 1 --recursive `
60+ command. This command runs in a temporary directory on your local host. After
61+ the command succeeds, the directory is sent to the Docker daemon as the
62+ context. Local clones give you the ability to access private repositories using
63+ local user credentials, VPN's, and so forth.
5964
6065Git URLs accept context configuration in their fragment section, separated by a
6166colon ` : ` . The first part represents the reference that Git will check out,
@@ -84,9 +89,29 @@ Build Syntax Suffix | Commit Used | Build Context Used
8489` myrepo.git#mybranch:myfolder ` | ` refs/heads/mybranch ` | ` /myfolder `
8590` myrepo.git#abcdef:myfolder ` | ` sha1 = abcdef ` | ` /myfolder `
8691
92+
93+ ### Tarball contexts
94+
95+ If you pass an URL to a remote tarball, the URL itself is sent to the daemon:
96+
8797Instead of specifying a context, you can pass a single Dockerfile in the ` URL `
8898or pipe the file in via ` STDIN ` . To pipe a Dockerfile from ` STDIN ` :
8999
100+ ``` bash
101+ $ docker build http://server/context.tar.gz
102+
103+ The download operation will be performed on the host the Docker daemon is
104+ running on, which is not necessarily the same host from which the build command
105+ is being issued. The Docker daemon will fetch ` context.tar.gz` and use it as the
106+ build context. Tarball contexts must be tar archives conforming to the standard
107+ ` tar` UNIX format and can be compressed with any one of the ' xz' , ' bzip2' ,
108+ ' gzip' or ' identity' (no compression) formats.
109+
110+ # ## Text files
111+
112+ Instead of specifying a context, you can pass a single ` Dockerfile` in the
113+ ` URL` or pipe the file in via ` STDIN` . To pipe a ` Dockerfile` from ` STDIN` :
114+
90115` ` ` bash
91116$ docker build - < Dockerfile
92117` ` `
@@ -97,16 +122,16 @@ With Powershell on Windows, you can run:
97122Get-Content Dockerfile | docker build -
98123` ` `
99124
100- If you use STDIN or specify a ` URL ` , the system places the contents into a file
101- called ` Dockerfile ` , and any ` -f ` , ` --file ` option is ignored. In this
102- scenario, there is no context.
125+ If you use ` STDIN` or specify a ` URL` pointing to a plain text file, the system
126+ places the contents into a file called ` Dockerfile` , and any ` -f` , ` --file`
127+ option is ignored. In this scenario, there is no context.
103128
104129By default the ` docker build` command will look for a ` Dockerfile` at the root
105130of the build context. The ` -f` , ` --file` , option lets you specify the path to
106131an alternative file to use instead. This is useful in cases where the same set
107132of files are used for multiple builds. The path must be to a file within the
108- build context. If a relative path is specified then it must to be relative to
109- the current directory .
133+ build context. If a relative path is specified then it is interpreted as
134+ relative to the root of the context .
110135
111136In most cases, it' s best to put each Dockerfile in an empty directory. Then,
112137add to that directory only the files needed for building the Dockerfile. To
@@ -199,9 +224,32 @@ $ docker build github.com/creack/docker-firefox
199224```
200225
201226This will clone the GitHub repository and use the cloned repository as context.
202- The Dockerfile at the root of the repository is used as Dockerfile. Note that
203- you can specify an arbitrary Git repository by using the ` git:// ` or ` git@ `
204- scheme.
227+ The Dockerfile at the root of the repository is used as Dockerfile. You can
228+ specify an arbitrary Git repository by using the `git://` or `git@` scheme.
229+
230+ ```bash
231+ $ docker build -f ctx/Dockerfile http://server/ctx.tar.gz
232+
233+ Downloading context: http://server/ctx.tar.gz [===================>] 240 B/240 B
234+ Step 0 : FROM busybox
235+ ---> 8c2e06607696
236+ Step 1 : ADD ctx/container.cfg /
237+ ---> e7829950cee3
238+ Removing intermediate container b35224abf821
239+ Step 2 : CMD /bin/ls
240+ ---> Running in fbc63d321d73
241+ ---> 3286931702ad
242+ Removing intermediate container fbc63d321d73
243+ Successfully built 377c409b35e4
244+ ```
245+
246+ This sends the URL `http://server/ctx.tar.gz` to the Docker daemon, which
247+ downloads and extracts the referenced tarball. The `-f ctx/Dockerfile`
248+ parameter specifies a path inside `ctx.tar.gz` to the `Dockerfile` that is used
249+ to build the image. Any `ADD` commands in that `Dockerfile` that refer to local
250+ paths must be relative to the root of the contents inside `ctx.tar.gz`. In the
251+ example above, the tarball contains a directory `ctx/`, so the `ADD
252+ ctx/container.cfg /` operation works as expected.
205253
206254### Build with -
207255
0 commit comments