Signed-off-by: sandyskies <chenmingjie0828@163.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
| ... | ... |
@@ -51,6 +51,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui |
| 51 | 51 |
options.CPUSetCPUs = r.FormValue("cpusetcpus")
|
| 52 | 52 |
options.CPUSetMems = r.FormValue("cpusetmems")
|
| 53 | 53 |
options.CgroupParent = r.FormValue("cgroupparent")
|
| 54 |
+ options.NetworkMode = r.FormValue("networkmode")
|
|
| 54 | 55 |
options.Tags = r.Form["t"] |
| 55 | 56 |
options.SecurityOpt = r.Form["securityopt"] |
| 56 | 57 |
|
| ... | ... |
@@ -58,6 +58,7 @@ type buildOptions struct {
|
| 58 | 58 |
cacheFrom []string |
| 59 | 59 |
compress bool |
| 60 | 60 |
securityOpt []string |
| 61 |
+ networkMode string |
|
| 61 | 62 |
} |
| 62 | 63 |
|
| 63 | 64 |
// NewBuildCommand creates a new `docker build` command |
| ... | ... |
@@ -105,6 +106,7 @@ func NewBuildCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 105 | 105 |
flags.StringSliceVar(&options.cacheFrom, "cache-from", []string{}, "Images to consider as cache sources")
|
| 106 | 106 |
flags.BoolVar(&options.compress, "compress", false, "Compress the build context using gzip") |
| 107 | 107 |
flags.StringSliceVar(&options.securityOpt, "security-opt", []string{}, "Security options")
|
| 108 |
+ flags.StringVar(&options.networkMode, "network", "default", "Connect a container to a network") |
|
| 108 | 109 |
|
| 109 | 110 |
command.AddTrustedFlags(flags, true) |
| 110 | 111 |
|
| ... | ... |
@@ -302,6 +304,7 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error {
|
| 302 | 302 |
Labels: runconfigopts.ConvertKVStringsToMap(options.labels.GetAll()), |
| 303 | 303 |
CacheFrom: options.cacheFrom, |
| 304 | 304 |
SecurityOpt: options.securityOpt, |
| 305 |
+ NetworkMode: options.networkMode, |
|
| 305 | 306 |
} |
| 306 | 307 |
|
| 307 | 308 |
response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions) |
| ... | ... |
@@ -84,6 +84,7 @@ func imageBuildOptionsToQuery(options types.ImageBuildOptions) (url.Values, erro |
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 | 86 |
query.Set("cpusetcpus", options.CPUSetCPUs)
|
| 87 |
+ query.Set("networkmode", options.NetworkMode)
|
|
| 87 | 88 |
query.Set("cpusetmems", options.CPUSetMems)
|
| 88 | 89 |
query.Set("cpushares", strconv.FormatInt(options.CPUShares, 10))
|
| 89 | 90 |
query.Set("cpuquota", strconv.FormatInt(options.CPUQuota, 10))
|
| ... | ... |
@@ -130,6 +130,7 @@ This section lists each version from latest to oldest. Each listing includes a |
| 130 | 130 |
|
| 131 | 131 |
[Docker Remote API v1.25](docker_remote_api_v1.25.md) documentation |
| 132 | 132 |
|
| 133 |
+* `POST /build` accepts `networkmode` parameter to specify network used during build. |
|
| 133 | 134 |
* `GET /images/(name)/json` now returns `OsVersion` if populated |
| 134 | 135 |
* `GET /info` now returns `Isolation`. |
| 135 | 136 |
* `POST /containers/create` now takes `AutoRemove` in HostConfig, to enable auto-removal of the container on daemon side when the container's process exits. |
| ... | ... |
@@ -1788,6 +1788,11 @@ or being killed. |
| 1788 | 1788 |
passing secret values. [Read more about the buildargs instruction](../../reference/builder.md#arg) |
| 1789 | 1789 |
- **shmsize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. |
| 1790 | 1790 |
- **labels** – JSON map of string pairs for labels to set on the image. |
| 1791 |
+- **networkmode** - Sets the networking mode for the run commands during |
|
| 1792 |
+ build. Supported standard values are: `bridge`, `host`, `none`, and |
|
| 1793 |
+ `container:<name|id>`. Any other value is taken as a custom network's |
|
| 1794 |
+ name to which this container should connect to. |
|
| 1795 |
+ |
|
| 1791 | 1796 |
|
| 1792 | 1797 |
**Request Headers**: |
| 1793 | 1798 |
|
| ... | ... |
@@ -38,6 +38,13 @@ Options: |
| 38 | 38 |
--label value Set metadata for an image (default []) |
| 39 | 39 |
-m, --memory string Memory limit |
| 40 | 40 |
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap |
| 41 |
+ --network string Set the networking mode for the run commands |
|
| 42 |
+ during build. |
|
| 43 |
+ 'bridge': use default Docker bridge |
|
| 44 |
+ 'none': no networking |
|
| 45 |
+ 'container:<name|id>': reuse another container's network stack |
|
| 46 |
+ 'host': use the Docker host network stack |
|
| 47 |
+ '<network-name>|<network-id>': connect to a user-defined network |
|
| 41 | 48 |
--no-cache Do not use cache when building the image |
| 42 | 49 |
--pull Always attempt to pull a newer version of the image |
| 43 | 50 |
-q, --quiet Suppress the build output and print image ID on success |
| ... | ... |
@@ -22,6 +22,7 @@ docker-build - Build a new image from the source code at PATH |
| 22 | 22 |
[**-t**|**--tag**[=*[]*]] |
| 23 | 23 |
[**-m**|**--memory**[=*MEMORY*]] |
| 24 | 24 |
[**--memory-swap**[=*LIMIT*]] |
| 25 |
+[**--network**[=*"default"*]] |
|
| 25 | 26 |
[**--shm-size**[=*SHM-SIZE*]] |
| 26 | 27 |
[**--cpu-period**[=*0*]] |
| 27 | 28 |
[**--cpu-quota**[=*0*]] |
| ... | ... |
@@ -111,6 +112,9 @@ set as the **URL**, the repository is cloned locally and then sent as the contex |
| 111 | 111 |
`k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a |
| 112 | 112 |
unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap. |
| 113 | 113 |
|
| 114 |
+**--network**=*NETWORK* |
|
| 115 |
+ |
|
| 116 |
+ |
|
| 114 | 117 |
**--shm-size**=*SHM-SIZE* |
| 115 | 118 |
Size of `/dev/shm`. The format is `<number><unit>`. `number` must be greater than `0`. |
| 116 | 119 |
Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you omit the unit, the system uses bytes. |
| ... | ... |
@@ -388,7 +388,7 @@ string name. The name is useful when defining links (see **--link**) (or any |
| 388 | 388 |
other place you need to identify a container). This works for both background |
| 389 | 389 |
and foreground Docker containers. |
| 390 | 390 |
|
| 391 |
-**--net**="*bridge*" |
|
| 391 |
+**--network**="*bridge*" |
|
| 392 | 392 |
Set the Network mode for the container |
| 393 | 393 |
'bridge': create a network stack on the default Docker bridge |
| 394 | 394 |
'none': no networking |