Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 14944da

Browse files
Merge component 'cli' from git@github.com:docker/cli 19.03
2 parents 3552b02 + d60a0ce commit 14944da

40 files changed

Lines changed: 293 additions & 92 deletions

components/cli/circle.yml

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,27 @@ jobs:
1414
reusable: true
1515
exclusive: false
1616
- run:
17+
name: "Docker version"
1718
command: docker version
1819
- run:
19-
name: "Lint"
20+
name: "Docker info"
21+
command: docker info
22+
- run:
23+
name: "Shellcheck - build image"
24+
command: |
25+
docker build --progress=plain -f dockerfiles/Dockerfile.shellcheck --tag cli-validator:$CIRCLE_BUILD_NUM .
26+
- run:
27+
name: "Shellcheck"
28+
command: |
29+
docker run --rm cli-validator:$CIRCLE_BUILD_NUM \
30+
make shellcheck
31+
- run:
32+
name: "Lint - build image"
2033
command: |
2134
docker build --progress=plain -f dockerfiles/Dockerfile.lint --tag cli-linter:$CIRCLE_BUILD_NUM .
35+
- run:
36+
name: "Lint"
37+
command: |
2238
docker run --rm cli-linter:$CIRCLE_BUILD_NUM
2339
2440
cross:
@@ -34,9 +50,18 @@ jobs:
3450
reusable: true
3551
exclusive: false
3652
- run:
37-
name: "Cross"
53+
name: "Docker version"
54+
command: docker version
55+
- run:
56+
name: "Docker info"
57+
command: docker info
58+
- run:
59+
name: "Cross - build image"
3860
command: |
3961
docker build --progress=plain -f dockerfiles/Dockerfile.cross --tag cli-builder:$CIRCLE_BUILD_NUM .
62+
- run:
63+
name: "Cross"
64+
command: |
4065
name=cross-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX
4166
docker run \
4267
-e CROSS_GROUP=$CIRCLE_NODE_INDEX \
@@ -60,10 +85,19 @@ jobs:
6085
reusable: true
6186
exclusive: false
6287
- run:
63-
name: "Unit Test with Coverage"
88+
name: "Docker version"
89+
command: docker version
90+
- run:
91+
name: "Docker info"
92+
command: docker info
93+
- run:
94+
name: "Unit Test with Coverage - build image"
6495
command: |
6596
mkdir -p test-results/unit-tests
6697
docker build --progress=plain -f dockerfiles/Dockerfile.dev --tag cli-builder:$CIRCLE_BUILD_NUM .
98+
- run:
99+
name: "Unit Test with Coverage"
100+
command: |
67101
docker run \
68102
-e GOTESTSUM_JUNITFILE=/tmp/junit.xml \
69103
--name \
@@ -98,30 +132,23 @@ jobs:
98132
reusable: true
99133
exclusive: false
100134
- run:
101-
name: "Validate Vendor, Docs, and Code Generation"
135+
name: "Docker version"
136+
command: docker version
137+
- run:
138+
name: "Docker info"
139+
command: docker info
140+
- run:
141+
name: "Validate - build image"
102142
command: |
103143
rm -f .dockerignore # include .git
104144
docker build --progress=plain -f dockerfiles/Dockerfile.dev --tag cli-builder-with-git:$CIRCLE_BUILD_NUM .
145+
- run:
146+
name: "Validate Vendor, Docs, and Code Generation"
147+
command: |
105148
docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \
106149
make ci-validate
107150
no_output_timeout: 15m
108-
shellcheck:
109-
working_directory: /work
110-
docker: [{image: 'docker:18.09-git'}]
111-
environment:
112-
DOCKER_BUILDKIT: 1
113-
steps:
114-
- checkout
115-
- setup_remote_docker:
116-
version: 18.09.3
117-
reusable: true
118-
exclusive: false
119-
- run:
120-
name: "Run shellcheck"
121-
command: |
122-
docker build --progress=plain -f dockerfiles/Dockerfile.shellcheck --tag cli-validator:$CIRCLE_BUILD_NUM .
123-
docker run --rm cli-validator:$CIRCLE_BUILD_NUM \
124-
make shellcheck
151+
125152
workflows:
126153
version: 2
127154
ci:
@@ -130,4 +157,3 @@ workflows:
130157
- cross
131158
- test
132159
- validate
133-
- shellcheck

components/cli/cli/command/image/build/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ func getWithStatusError(url string) (resp *http.Response, err error) {
243243
body, err := ioutil.ReadAll(resp.Body)
244244
resp.Body.Close()
245245
if err != nil {
246-
return nil, errors.Wrapf(err, msg+": error reading body")
246+
return nil, errors.Wrapf(err, "%s: error reading body", msg)
247247
}
248-
return nil, errors.Errorf(msg+": %s", bytes.TrimSpace(body))
248+
return nil, errors.Errorf("%s: %s", msg, bytes.TrimSpace(body))
249249
}
250250

251251
// GetContextFromLocalDir uses the given local directory as context for a

components/cli/cli/command/image/pull_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ func TestNewPullCommandSuccess(t *testing.T) {
5050
testCases := []struct {
5151
name string
5252
args []string
53-
flags map[string]string
5453
expectedTag string
5554
}{
5655
{
@@ -64,11 +63,8 @@ func TestNewPullCommandSuccess(t *testing.T) {
6463
expectedTag: "image:latest",
6564
},
6665
{
67-
name: "simple-quiet",
68-
args: []string{"image"},
69-
flags: map[string]string{
70-
"quiet": "true",
71-
},
66+
name: "simple-quiet",
67+
args: []string{"--quiet", "image"},
7268
expectedTag: "image:latest",
7369
},
7470
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Using default tag: latest
21
docker.io/library/image:latest

components/cli/cli/config/configfile/file.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ func (configFile *ConfigFile) LoadFromReader(configData io.Reader) error {
123123
}
124124
var err error
125125
for addr, ac := range configFile.AuthConfigs {
126-
ac.Username, ac.Password, err = decodeAuth(ac.Auth)
127-
if err != nil {
128-
return err
126+
if ac.Auth != "" {
127+
ac.Username, ac.Password, err = decodeAuth(ac.Auth)
128+
if err != nil {
129+
return err
130+
}
129131
}
130132
ac.Auth = ""
131133
ac.ServerAddress = addr

components/cli/cli/config/configfile/file_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package configfile
22

33
import (
44
"bytes"
5+
"encoding/json"
56
"io/ioutil"
67
"os"
78
"testing"
@@ -380,6 +381,41 @@ func TestGetAllCredentialsCredHelperOverridesDefaultStore(t *testing.T) {
380381
assert.Check(t, is.Equal(0, testCredHelper.(*mockNativeStore).GetAllCallCount))
381382
}
382383

384+
func TestLoadFromReaderWithUsernamePassword(t *testing.T) {
385+
configFile := New("test-load")
386+
defer os.Remove("test-load")
387+
388+
want := types.AuthConfig{
389+
Username: "user",
390+
Password: "pass",
391+
}
392+
393+
for _, tc := range []types.AuthConfig{
394+
want,
395+
{
396+
Auth: encodeAuth(&want),
397+
},
398+
} {
399+
cf := ConfigFile{
400+
AuthConfigs: map[string]types.AuthConfig{
401+
"example.com/foo": tc,
402+
},
403+
}
404+
405+
b, err := json.Marshal(cf)
406+
assert.NilError(t, err)
407+
408+
err = configFile.LoadFromReader(bytes.NewReader(b))
409+
assert.NilError(t, err)
410+
411+
got, err := configFile.GetAuthConfig("example.com/foo")
412+
assert.NilError(t, err)
413+
414+
assert.Check(t, is.DeepEqual(want.Username, got.Username))
415+
assert.Check(t, is.DeepEqual(want.Password, got.Password))
416+
}
417+
}
418+
383419
func TestCheckKubernetesConfigurationRaiseAnErrorOnInvalidValue(t *testing.T) {
384420
testCases := []struct {
385421
name string

components/cli/docs/reference/builder.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Practices](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-pr
2828

2929
## Usage
3030

31-
The [`docker build`](commandline/build.md) command builds an image from
31+
The [docker build](commandline/build.md) command builds an image from
3232
a `Dockerfile` and a *context*. The build's context is the set of files at a
3333
specified location `PATH` or `URL`. The `PATH` is a directory on your local
3434
filesystem. The `URL` is a Git repository location.
@@ -93,8 +93,7 @@ instructions.
9393
Whenever possible, Docker will re-use the intermediate images (cache),
9494
to accelerate the `docker build` process significantly. This is indicated by
9595
the `Using cache` message in the console output.
96-
(For more information, see the [Build cache section](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#build-cache) in the
97-
`Dockerfile` best practices guide):
96+
(For more information, see the [`Dockerfile` best practices guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/):
9897

9998
$ docker build -t svendowideit/ambassador .
10099
Sending build context to Docker daemon 15.36 kB
@@ -137,7 +136,7 @@ implementation. For example, BuildKit can:
137136
* Avoid side-effects with rest of the API (intermediate images and containers)
138137
* Prioritize your build cache for automatic pruning
139138

140-
To use the BuildKit backend, you need to set an environment variable
139+
To use the BuildKit backend, you need to set an environment variable
141140
`DOCKER_BUILDKIT=1` on the CLI before invoking `docker build`.
142141

143142
To learn about the experimental Dockerfile syntax available to BuildKit-based
@@ -269,7 +268,7 @@ This feature is only enabled if the [BuildKit](#buildkit) backend is used.
269268

270269
The syntax directive defines the location of the Dockerfile builder that is used for
271270
building the current Dockerfile. The BuildKit backend allows to seamlessly use
272-
external implementations of builders that are distributed as Docker images and
271+
external implementations of builders that are distributed as Docker images and
273272
execute inside a container sandbox environment.
274273

275274
Custom Dockerfile implementation allows you to:
@@ -280,9 +279,9 @@ Custom Dockerfile implementation allows you to:
280279

281280
### Official releases
282281

283-
Docker distributes official versions of the images that can be used for building
284-
Dockerfiles under `docker/dockerfile` repository on Docker Hub. There are two
285-
channels where new images are released: stable and experimental.
282+
Docker distributes official versions of the images that can be used for building
283+
Dockerfiles under `docker/dockerfile` repository on Docker Hub. There are two
284+
channels where new images are released: stable and experimental.
286285

287286
Stable channel follows semantic versioning. For example:
288287

@@ -298,9 +297,9 @@ component from the stable channel on the time of the release. For example:
298297
- docker/dockerfile:1.0-experimental - latest experimental releases after 1.0
299298
- docker/dockerfile:experimental - latest release on experimental channel
300299

301-
You should choose a channel that best fits your needs. If you only want
300+
You should choose a channel that best fits your needs. If you only want
302301
bugfixes, you should use `docker/dockerfile:1.0`. If you want to benefit from
303-
experimental features, you should use the experimental channel. If you are using
302+
experimental features, you should use the experimental channel. If you are using
304303
the experimental channel, newer releases may not be backwards compatible, so it
305304
is recommended to use an immutable full version variant.
306305

@@ -571,7 +570,7 @@ Or
571570
FROM [--platform=<platform>] <image>[@<digest>] [AS <name>]
572571

573572
The `FROM` instruction initializes a new build stage and sets the
574-
[*Base Image*](glossary.md#base-image) for subsequent instructions. As such, a
573+
[*Base Image*](../../glossary/#base-image) for subsequent instructions. As such, a
575574
valid `Dockerfile` must start with a `FROM` instruction. The image can be
576575
any valid image – it is especially easy to start by **pulling an image** from
577576
the [*Public Repositories*](https://docs.docker.com/engine/tutorials/dockerrepos/).
@@ -694,7 +693,7 @@ cache for `RUN` instructions can be invalidated by using the `--no-cache`
694693
flag, for example `docker build --no-cache`.
695694

696695
See the [`Dockerfile` Best Practices
697-
guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/build-cache) for more information.
696+
guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/) for more information.
698697

699698
The cache for `RUN` instructions can be invalidated by `ADD` instructions. See
700699
[below](#add) for details.
@@ -1015,7 +1014,7 @@ of whether or not the file has changed and the cache should be updated.
10151014
> following instructions from the Dockerfile if the contents of `<src>` have
10161015
> changed. This includes invalidating the cache for `RUN` instructions.
10171016
> See the [`Dockerfile` Best Practices
1018-
guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/build-cache) for more information.
1017+
guide](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/) for more information.
10191018

10201019

10211020
`ADD` obeys the following rules:
@@ -1436,7 +1435,7 @@ containers. The value can be a JSON array, `VOLUME ["/var/log/"]`, or a plain
14361435
string with multiple arguments, such as `VOLUME /var/log` or `VOLUME /var/log
14371436
/var/db`. For more information/examples and mounting instructions via the
14381437
Docker client, refer to
1439-
[*Share Directories via Volumes*](https://docs.docker.com/engine/tutorials/dockervolumes/#/mount-a-host-directory-as-a-data-volume)
1438+
[*Share Directories via Volumes*](https://docs.docker.com/engine/tutorials/dockervolumes/)
14401439
documentation.
14411440

14421441
The `docker run` command initializes the newly created volume with any data
@@ -2055,13 +2054,12 @@ The `SHELL` feature was added in Docker 1.12.
20552054
This feature is only available when using the [BuildKit](#buildkit) backend.
20562055

20572056
Docker build supports experimental features like cache mounts, build secrets and
2058-
ssh forwarding that are enabled by using an external implementation of the
2057+
ssh forwarding that are enabled by using an external implementation of the
20592058
builder with a syntax directive. To learn about these features, [refer to the documentation in BuildKit repository](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md).
20602059

20612060
## Dockerfile examples
20622061

2063-
Below you can see some examples of Dockerfile syntax. If you're interested in
2064-
something more realistic, take a look at the list of [Dockerization examples](https://docs.docker.com/engine/examples/).
2062+
Below you can see some examples of Dockerfile syntax.
20652063

20662064
```
20672065
# Nginx

components/cli/docs/reference/commandline/cli.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,23 @@ running `docker stack` management commands. Valid values are `"swarm"`,
221221
`"kubernetes"`, and `"all"`. This property can be overridden with the
222222
`DOCKER_STACK_ORCHESTRATOR` environment variable, or the `--orchestrator` flag.
223223

224+
The property `proxies` specifies proxy environment variables to be automatically
225+
set on containers, and set as `--build-arg` on containers used during `docker build`.
226+
A `"default"` set of proxies can be configured, and will be used for any docker
227+
daemon that the client connects to, or a configuration per host (docker daemon),
228+
for example, "https://docker-daemon1.example.com". The following properties can
229+
be set for each environment:
230+
231+
* `httpProxy` (sets the value of `HTTP_PROXY` and `http_proxy`)
232+
* `httpsProxy` (sets the value of `HTTPS_PROXY` and `https_proxy`)
233+
* `ftpProxy` (sets the value of `FTP_PROXY` and `ftp_proxy`)
234+
* `noProxy` (sets the value of `NO_PROXY` and `no_proxy`)
235+
236+
> **Warning**: Proxy settings may contain sensitive information (for example,
237+
> if the proxy requires authentication). Environment variables are stored as
238+
> plain text in the container's configuration, and as such can be inspected
239+
> through the remote API or committed to an image when using `docker commit`.
240+
224241
Once attached to a container, users detach from it and leave it running using
225242
the using `CTRL-p CTRL-q` key sequence. This detach key sequence is customizable
226243
using the `detachKeys` property. Specify a `<sequence>` value for the
@@ -275,6 +292,18 @@ Following is a sample `config.json` file:
275292
"anotheroption": "anothervalue",
276293
"athirdoption": "athirdvalue"
277294
}
295+
},
296+
"proxies": {
297+
"default": {
298+
"httpProxy": "http://user:pass@example.com:3128",
299+
"httpsProxy": "http://user:pass@example.com:3128",
300+
"noProxy": "http://user:pass@example.com:3128",
301+
"ftpProxy": "http://user:pass@example.com:3128"
302+
},
303+
"https://manager1.mycorp.example.com:2377": {
304+
"httpProxy": "http://user:pass@example.com:3128",
305+
"httpsProxy": "http://user:pass@example.com:3128"
306+
},
278307
}
279308
}
280309
{% endraw %}

components/cli/docs/reference/commandline/network_create.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ a single overlay network. Each of the subnetworks has 126 usable addresses.
159159

160160
```bash
161161
$ docker network create -d overlay \
162-
--subnet=192.168.1.0/25 \
163-
--subnet=192.170.2.0/25 \
164-
--gateway=192.168.1.100 \
165-
--gateway=192.170.2.100 \
166-
--aux-address="my-router=192.168.1.5" --aux-address="my-switch=192.168.1.6" \
167-
--aux-address="my-printer=192.170.1.5" --aux-address="my-nas=192.170.1.6" \
162+
--subnet=192.168.10.0/25 \
163+
--subnet=192.168.20.0/25 \
164+
--gateway=192.168.10.100 \
165+
--gateway=192.168.20.100 \
166+
--aux-address="my-router=192.168.10.5" --aux-address="my-switch=192.168.10.6" \
167+
--aux-address="my-printer=192.168.20.5" --aux-address="my-nas=192.168.20.6" \
168168
my-multihost-network
169169
```
170170

0 commit comments

Comments
 (0)