Skip to content

Commit e7cdabe

Browse files
authored
Merge pull request #3918 from thaJeztah/20.10_docs_backports
[20.10 backport] assorted docs fixes
2 parents 5106d8e + ce10682 commit e7cdabe

File tree

5 files changed

+122
-39
lines changed

5 files changed

+122
-39
lines changed

docs/reference/builder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ If an environment variable is only needed during build, and not in the final
10601060
image, consider setting a value for a single command instead:
10611061
10621062
```dockerfile
1063-
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ...
1063+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ...
10641064
```
10651065
10661066
Or using [`ARG`](#arg), which is not persisted in the final image:

docs/reference/commandline/inspect.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ By default, `docker inspect` will render results in a JSON array.
2929

3030
If a format is specified, the given template will be executed for each result.
3131

32-
Go's [text/template](https://golang.org/pkg/text/template/) package
33-
describes all the details of the format.
32+
Go's [text/template](https://golang.org/pkg/text/template/) package describes
33+
all the details of the format.
3434

3535
## Specify target type (--type)
3636

3737
`--type container|image|node|network|secret|service|volume|task|plugin`
3838

39-
The `docker inspect` command matches any type of object by either ID or name.
40-
In some cases multiple type of objects (for example, a container and a volume)
39+
The `docker inspect` command matches any type of object by either ID or name. In
40+
some cases multiple type of objects (for example, a container and a volume)
4141
exist with the same name, making the result ambiguous.
4242

4343
To restrict `docker inspect` to a specific type of object, use the `--type`
@@ -49,6 +49,35 @@ The following example inspects a _volume_ named "myvolume"
4949
$ docker inspect --type=volume myvolume
5050
```
5151

52+
### <a name=size></a> Inspect the size of a container (-s, --size)
53+
54+
The `--size`, or short-form `-s`, option adds two additional fields to the
55+
`docker inspect` output. This option only works for containers. The container
56+
doesn't have to be running, it also works for stopped containers.
57+
58+
```console
59+
$ docker inspect --size mycontainer
60+
```
61+
62+
The output includes the full output of a regular `docker inspect` command, with
63+
the following additional fields:
64+
65+
- `SizeRootFs`: the total size of all the files in the container, in bytes.
66+
- `SizeRw`: the size of the files that have been created or changed in the
67+
container, compared to it's image, in bytes.
68+
69+
```console
70+
$ docker run --name database -d redis
71+
3b2cbf074c99db4a0cad35966a9e24d7bc277f5565c17233386589029b7db273
72+
$ docker inspect --size database -f '{{ .SizeRootFs }}'
73+
123125760
74+
$ docker inspect --size database -f '{{ .SizeRw }}'
75+
8192
76+
$ docker exec database fallocate -l 1000 /newfile
77+
$ docker inspect --size database -f '{{ .SizeRw }}'
78+
12288
79+
```
80+
5281
## Examples
5382

5483
### Get an instance's IP address
@@ -80,33 +109,30 @@ $ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
80109

81110
### List all port bindings
82111

83-
You can loop over arrays and maps in the results to produce simple text
84-
output:
112+
You can loop over arrays and maps in the results to produce simple text output:
85113

86114
```console
87115
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
88116
```
89117

90118
### Find a specific port mapping
91119

92-
The `.Field` syntax doesn't work when the field name begins with a
93-
number, but the template language's `index` function does. The
94-
`.NetworkSettings.Ports` section contains a map of the internal port
95-
mappings to a list of external address/port objects. To grab just the
96-
numeric public port, you use `index` to find the specific port map, and
97-
then `index` 0 contains the first object inside of that. Then we ask for
98-
the `HostPort` field to get the public address.
120+
The `.Field` syntax doesn't work when the field name begins with a number, but
121+
the template language's `index` function does. The `.NetworkSettings.Ports`
122+
section contains a map of the internal port mappings to a list of external
123+
address/port objects. To grab just the numeric public port, you use `index` to
124+
find the specific port map, and then `index` 0 contains the first object inside
125+
of that. Then we ask for the `HostPort` field to get the public address.
99126

100127
```console
101128
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
102129
```
103130

104131
### Get a subsection in JSON format
105132

106-
If you request a field which is itself a structure containing other
107-
fields, by default you get a Go-style dump of the inner values.
108-
Docker adds a template function, `json`, which can be applied to get
109-
results in JSON format.
133+
If you request a field which is itself a structure containing other fields, by
134+
default you get a Go-style dump of the inner values. Docker adds a template
135+
function, `json`, which can be applied to get results in JSON format.
110136

111137
```console
112138
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID

docs/reference/commandline/logs.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ Options:
2525

2626
The `docker logs` command batch-retrieves logs present at the time of execution.
2727

28-
> **Note**
29-
>
30-
> This command is only functional for containers that are started with the
31-
> `json-file` or `journald` logging driver.
32-
3328
For more information about selecting and configuring logging drivers, refer to
3429
[Configure logging drivers](https://docs.docker.com/config/containers/logging/configure/).
3530

docs/reference/commandline/version.md

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,91 @@ Options:
1919

2020
## Description
2121

22-
By default, this will render all version information in an easy to read
23-
layout. If a format is specified, the given template will be executed instead.
22+
The version command prints the current version number for all independently
23+
versioned Docker components. Use the [`--format`](#format) option to customize
24+
the output.
2425

25-
Go's [text/template](https://golang.org/pkg/text/template/) package
26-
describes all the details of the format.
27-
28-
## Examples
26+
The version command (`docker version`) outputs the version numbers of Docker
27+
components, while the `--version` flag (`docker --version`) outputs the version
28+
number of the Docker CLI you are using.
2929

3030
### Default output
3131

32+
The default output renders all version information divided into two sections;
33+
the "Client" section contains information about the Docker CLI and client
34+
components, and the "Server" section contains information about the Docker
35+
Engine and components used by the Engine, such as the "Containerd" and "Runc"
36+
OCI Runtimes.
37+
38+
The information shown may differ depending on how you installed Docker and
39+
what components are in use. The following example shows the output on a macOS
40+
machine running Docker Desktop:
41+
3242
```console
3343
$ docker version
3444

3545
Client:
36-
Version: 19.03.8
37-
API version: 1.40
38-
Go version: go1.12.17
39-
Git commit: afacb8b
40-
Built: Wed Mar 11 01:21:11 2020
46+
Version: 20.10.16
47+
API version: 1.41
48+
Go version: go1.17.10
49+
Git commit: aa7e414
50+
Built: Thu May 12 09:17:28 2022
4151
OS/Arch: darwin/amd64
4252
Context: default
43-
Experimental: true
4453

45-
Server:
54+
Server: Docker Desktop 4.8.2 (77141)
55+
Engine:
56+
Version: 20.10.16
57+
API version: 1.41 (minimum version 1.12)
58+
Go version: go1.17.10
59+
Git commit: f756502
60+
Built: Thu May 12 09:15:33 2022
61+
OS/Arch: linux/amd64
62+
Experimental: false
63+
containerd:
64+
Version: 1.6.4
65+
GitCommit: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
66+
runc:
67+
Version: 1.1.1
68+
GitCommit: v1.1.1-0-g52de29d
69+
docker-init:
70+
Version: 0.19.0
71+
GitCommit: de40ad0
72+
```
73+
74+
### Client and server versions
75+
76+
Docker uses a client/server architecture, which allows you to use the Docker CLI
77+
on your local machine to control a Docker Engine running on a remote machine,
78+
which can be (for example) a machine running in the Cloud or inside a Virtual Machine.
79+
80+
The following example switches the Docker CLI to use a [context](context.md)
81+
named "remote-test-server", which runs an older version of the Docker Engine
82+
on a Linux server:
83+
84+
```console
85+
$ docker context use remote-test-server
86+
remote-test-server
87+
88+
$ docker version
89+
90+
Client:
91+
Version: 20.10.16
92+
API version: 1.40 (downgraded from 1.41)
93+
Go version: go1.17.10
94+
Git commit: aa7e414
95+
Built: Thu May 12 09:17:28 2022
96+
OS/Arch: darwin/amd64
97+
Context: remote-test-server
98+
99+
Server: Docker Engine - Community
46100
Engine:
47101
Version: 19.03.8
48102
API version: 1.40 (minimum version 1.12)
49103
Go version: go1.12.17
50104
Git commit: afacb8b
51105
Built: Wed Mar 11 01:29:16 2020
52106
OS/Arch: linux/amd64
53-
Experimental: true
54107
containerd:
55108
Version: v1.2.13
56109
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
@@ -62,12 +115,21 @@ Server:
62115
GitCommit: fec3683
63116
```
64117

118+
## Examples
119+
120+
### <a name=format></a> Format the output (--format)
121+
122+
The formatting option (`--format`) pretty-prints the output using a Go template,
123+
which allows you to customize the output format, or to obtain specific information
124+
from the output. Refer to the [format command and log output](https://docs.docker.com/config/formatting/)
125+
page for details of the format.
126+
65127
### Get the server version
66128

67129
```console
68130
$ docker version --format '{{.Server.Version}}'
69131

70-
19.03.8
132+
20.10.16
71133
```
72134

73135
### Dump raw JSON data

docs/reference/run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ the container exits**, you can add the `--rm` flag:
687687
| `--security-opt="label=level:LEVEL"` | Set the label level for the container |
688688
| `--security-opt="label=disable"` | Turn off label confinement for the container |
689689
| `--security-opt="apparmor=PROFILE"` | Set the apparmor profile to be applied to the container |
690-
| `--security-opt="no-new-privileges:true"` | Disable container processes from gaining new privileges |
690+
| `--security-opt="no-new-privileges=true"` | Disable container processes from gaining new privileges |
691691
| `--security-opt="seccomp=unconfined"` | Turn off seccomp confinement for the container |
692692
| `--security-opt="seccomp=profile.json"` | White-listed syscalls seccomp Json file to be used as a seccomp filter |
693693

0 commit comments

Comments
 (0)