From 174d9f0097026339c6dc7f661567e373f251e412 Mon Sep 17 00:00:00 2001 From: Tony Abboud Date: Fri, 13 Jan 2017 10:01:58 -0500 Subject: [PATCH] Add --add-host for docker build Signed-off-by: Tony Abboud --- docs/reference/commandline/build.md | 9 +++++++++ man/docker-build.1.md | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/docs/reference/commandline/build.md b/docs/reference/commandline/build.md index fc8183f1fa..962393dd5a 100644 --- a/docs/reference/commandline/build.md +++ b/docs/reference/commandline/build.md @@ -21,6 +21,7 @@ Usage: docker build [OPTIONS] PATH | URL | - Build an image from a Dockerfile Options: + --add-host value Add a custom host-to-IP mapping (host:ip) (default []) --build-arg value Set build-time variables (default []) --cache-from value Images to consider as cache sources (default []) --cgroup-parent string Optional parent cgroup for the container @@ -435,6 +436,13 @@ Linux namespaces. On Microsoft Windows, you can specify these values: Specifying the `--isolation` flag without a value is the same as setting `--isolation="default"`. +### Add entries to container hosts file (--add-host) + +You can add other hosts into a container's `/etc/hosts` file by using one or +more `--add-host` flags. This example adds a static address for a host named +`docker`: + + $ docker build --add-host=docker:10.180.0.1 . ### Squash an image's layers (--squash) **Experimental Only** @@ -451,3 +459,4 @@ space. **Note**: using this option you may see significantly more space used due to storing two copies of the image, one for the build cache with all the cache layers in tact, and one for the squashed version. + diff --git a/man/docker-build.1.md b/man/docker-build.1.md index 5676cb80bd..b650fc3aa2 100644 --- a/man/docker-build.1.md +++ b/man/docker-build.1.md @@ -6,6 +6,7 @@ docker-build - Build an image from a Dockerfile # SYNOPSIS **docker build** +[**--add-host**[=*[]*]] [**--build-arg**[=*[]*]] [**--cpu-shares**[=*0*]] [**--cgroup-parent**[=*CGROUP-PARENT*]] @@ -74,6 +75,12 @@ set as the **URL**, the repository is cloned locally and then sent as the contex storing two copies of the image, one for the build cache with all the cache layers in tact, and one for the squashed version. +**--add-host**=[] + Add a custom host-to-IP mapping (host:ip) + + Add a line to /etc/hosts. The format is hostname:ip. The **--add-host** +option can be set multiple times. + **--build-arg**=*variable* name and value of a **buildarg**.