1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration
Anca Iordache 427c7cc5f8
Add http(s) proxy properties to daemon configuration
This allows configuring the daemon's proxy server through the daemon.json con-
figuration file or command-line flags configuration file, in addition to the
existing option (through environment variables).

Configuring environment variables on Windows to configure a service is more
complicated than on Linux, and adding alternatives for this to the daemon con-
figuration makes the configuration more transparent and easier to use.

The configuration as set through command-line flags or through the daemon.json
configuration file takes precedence over env-vars in the daemon's environment,
which allows the daemon to use a different proxy. If both command-line flags
and a daemon.json configuration option is set, an error is produced when starting
the daemon.

Note that this configuration is not "live reloadable" due to Golang's use of
`sync.Once()` for proxy configuration, which means that changing the proxy
configuration requires a restart of the daemon (reload / SIGHUP will not update
the configuration.

With this patch:

    cat /etc/docker/daemon.json
    {
        "http-proxy": "http://proxytest.example.com:80",
        "https-proxy": "https://proxytest.example.com:443"
    }

    docker pull busybox
    Using default tag: latest
    Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp: lookup proxytest.example.com on 127.0.0.11:53: no such host

    docker build .
    Sending build context to Docker daemon  89.28MB
    Step 1/3 : FROM golang:1.16-alpine AS base
    Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp: lookup proxytest.example.com on 127.0.0.11:53: no such host

Integration tests were added to test the behavior:

- verify that the configuration through all means are used (env-var,
  command-line flags, damon.json), and used in the expected order of
  preference.
- verify that conflicting options produce an error.

Signed-off-by: Anca Iordache <anca.iordache@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-10-27 12:38:59 +02:00
..
build refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
config Add configuration validation option and tests. 2021-06-23 09:54:55 +00:00
container Fix racey TestHealthKillContainer 2021-10-21 19:27:07 +00:00
daemon Add http(s) proxy properties to daemon configuration 2021-10-27 12:38:59 +02:00
distribution bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
image refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
internal Update to Go 1.17.0, and gofmt with Go 1.17 2021-08-24 23:33:27 +02:00
network Update to Go 1.17.0, and gofmt with Go 1.17 2021-08-24 23:33:27 +02:00
plugin refactor: move from io/ioutil to io and os package 2021-08-27 14:56:57 +08:00
secret integration/secret: add check for empty list not producing an error 2020-04-14 18:31:36 +02:00
service Fix race in TestCreateServiceSecretFileMode, TestCreateServiceConfigFileMode 2021-10-27 10:55:54 +02:00
session bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
system Update to Go 1.17.0, and gofmt with Go 1.17 2021-08-24 23:33:27 +02:00
testdata/https Update test certificates 2021-05-18 09:43:21 +02:00
volume integration: copy loop variable into parallel test closures 2021-07-22 22:46:12 +02:00
doc.go Add canonical import comment 2018-02-05 16:51:57 -05:00