Commit Graph

120 Commits

Author SHA1 Message Date
fe5268e5c2 Merge pull request #31579 from ijc25/cpuacct
Correct CPU usage calculation in presence of offline CPUs and newer Linux
Upstream-commit: b786563826
Component: cli
2017-03-13 16:32:18 +00:00
0069d4e4ab Hide command options that are related to Windows
Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
Upstream-commit: c7dd91faf5
Component: cli
2017-03-12 08:47:17 +02:00
17822109ce Merge pull request #31582 from dnephin/misc-flag-cleanup
Cleanup some memory flags used in the CLI
Upstream-commit: be3e4bbe77
Component: cli
2017-03-10 14:16:42 +01:00
0a02d14545 Correct CPU usage calculation in presence of offline CPUs and newer Linux
In https://github.com/torvalds/linux/commit/5ca3726 (released in v4.7-rc1) the
content of the `cpuacct.usage_percpu` file in sysfs was changed to include both
online and offline cpus. This broke the arithmetic in the stats helpers used by
`docker stats`, since it was using the length of the PerCPUUsage array as a
proxy for the number of online CPUs.

Add current number of online CPUs to types.StatsJSON and use it in the
calculation.

Keep a fallback to `len(v.CPUStats.CPUUsage.PercpuUsage)` so this code
continues to work when talking to an older daemon. An old client talking to a
new daemon will ignore the new field and behave as before.

Fixes #28941.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
Upstream-commit: 54a5077ca5
Component: cli
2017-03-10 10:24:33 +00:00
c668006191 Fix description of docker run|create --stop-signal in help message
Signed-off-by: Harald Albers <github@albersweb.de>
Upstream-commit: 50a10e9bf4
Component: cli
2017-03-09 09:32:16 +01:00
20f2e36290 Use opts.MemBytes for flags.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: e43a97cd38
Component: cli
2017-03-07 10:32:49 -05:00
f341d1bde4 Merge pull request #31212 from fate-grand-order/fixed
use t.Fatal() to output the err message and fix typo
Upstream-commit: 76b6faa13d
Component: cli
2017-02-27 12:26:35 +09:00
5145dfe136 use t.Fatal() to output the err message where the values used for formatting
text does not appear to contain a placeholder

Signed-off-by: Helen Xie <chenjg@harmonycloud.cn>
Upstream-commit: 98c222239e
Component: cli
2017-02-23 10:16:22 +08:00
b7afa18df2 fix wrong print format
Signed-off-by: Reficul <xuzhenglun@gmail.com>
Upstream-commit: a77cf51173
Component: cli
2017-02-21 10:26:06 +08:00
6fa6de6703 why there are so many mistakes in our repo (up to /cmd)
Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
Upstream-commit: ca2aeb5a3e
Component: cli
2017-02-17 00:32:48 +08:00
bb64592fc8 Merge pull request #30457 from dmcgowan/distribution-reference-update-2
reference: use distribution reference and remove fork
Upstream-commit: 326583e728
Component: cli
2017-02-07 22:01:25 +01:00
78cba3d0ad Use distribution reference
Remove forked reference package. Use normalized named values
everywhere and familiar functions to convert back to familiar
strings for UX and storage compatibility.

Enforce that the source repository in the distribution metadata
is always a normalized string, ignore invalid values which are not.
Update distribution tests to use normalized values.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 635d686a88
Component: cli
2017-02-07 11:08:37 -08:00
3a4832fb11 Fix Windows docker stats showing Linux headers
This fix is an attempt to fix issue raised in #28005 where
`docker stats` on Windows shows Linux headers if there is
no containers in stats.

The reason for the issue is that, in case there is no container,
a header is faked in:
https://github.com/docker/docker/blob/v1.13.0/cli/command/formatter/formatter.go#L74-L78
which does not know OS type information (as OS was stored with container stat entries)

This fix tries to fix the issue by moving OS type information
to stats context (instead of individual container stats entry).

Additional unit tests have been added.

This fix fixes #28005.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: af80020ef2
Component: cli
2017-02-05 08:55:30 -08:00
4f8232c350 Merge pull request #30203 from allencloud/validate-healthcheck-params-in-daemon-side
validate healthcheck params in daemon side
Upstream-commit: 1ce67df34e
Component: cli
2017-02-01 21:19:30 -05:00
0fe55a8f05 Merge pull request #29747 from xlgao-zju/break-the-for
exit collect when we get EOF
Upstream-commit: 2454afb121
Component: cli
2017-02-01 22:29:18 +01:00
8d883b5e67 Merge pull request #29692 from yongtang/29492-daemon-shm-size
Add daemon option `--default-shm-size`
Upstream-commit: cb8723543e
Component: cli
2017-02-01 16:56:10 +01:00
b090b514cd Merge pull request #22563 from mlaventure/cgroup-devices
Allow adding rules to cgroup devices.allow on container create/run
Upstream-commit: 77467608bd
Component: cli
2017-02-01 16:29:34 +01:00
41c8dfca13 Merge pull request #30186 from thaJeztah/add-version-annotation-to-flags
Add version annotation to various flags added in 1.13
Upstream-commit: 2e02d615c4
Component: cli
2017-01-30 12:33:36 -08:00
2874513efc validate healthcheck params in daemon side
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 406c6348b6
Component: cli
2017-01-29 13:35:32 +08:00
6300064c81 Update opts.MemBytes to disable default, and move docker run/create/build to use opts.MemBytes
This fix made several updates:
1. Update opts.MemBytes so that default value will not show up.
   The reason is that in case a default value is decided by daemon,
   instead of client, we actually want to not show default value.
2. Move `docker run/create/build` to use opts.MemBytes for `--shm-size`
   This is to bring consistency between daemon and docker run
3. docs updates.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: f75ecc5ad2
Component: cli
2017-01-27 12:17:06 -08:00
e80af1f403 Allow adding rules to cgroup devices.allow on container create/run
This introduce a new `--device-cgroup-rule` flag that allow a user to
add one or more entry to the container cgroup device `devices.allow`

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Upstream-commit: f33bf818a2
Component: cli
2017-01-26 07:20:45 -08:00
eaf2723a5b Merge pull request #30043 from dmcgowan/distribution-reference-update-1
Distribution reference update
Upstream-commit: 96c7794e95
Component: cli
2017-01-24 20:38:20 -08:00
8868b20a7e Merge pull request #30291 from yongtang/30279-ps-format
Fix failure in `docker ps --format` when `.Label` has args
Upstream-commit: d62ccd9907
Component: cli
2017-01-24 17:55:52 -08:00
4c7cf08fd0 Fix failure in docker ps --format when .Label has args
This fix tries to fix the issue in 30279 where  `docker ps --format`
fails if `.Label` has args. For example:
```
docker ps --format '{{.ID}}\t{{.Names}}\t{{.Label "some.label"}}'
```

The reason for the failure is that during the preprocessing phase
to detect the existance of `.Size`, the `listOptionsProcessor`
does not has a method of `Label(name string) string`.

This results in the failure of
```
template: :1:24: executing "" at <.Label>: Label is not a method but has arguments
```

This fix fixes the issue by adding needed method of `Label(name string) string`.

This fix fixes 30279.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: a2afbcbb57
Component: cli
2017-01-23 09:31:48 -08:00
abe2284d28 fix flag descriptions for content-trust
Commit ed13c3abfb242905ec012e8255dc6f26dcf122f6 added flags
for Docker Content Trust. Depending on the `verify` boolean,
the message is "Skip image verification", or "Skip image signing".
"Signing" is intended for `docker push` / `docker plugin push`.

During the migration to Cobra, this boolean got flipped for
`docker push` (9640e3a4514f96a890310757a09fd77a3c70e931),
causing `docker push` to show the incorrect flag description.

This patch changes the flags to use the correct description
for `docker push`, and `docker plugin push`.

To prevent this confusion in future, the boolean argument
is removed, and a `AddTrustSigningFlags()` function is added.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 62ff1a0ea7
Component: cli
2017-01-23 14:52:36 +01:00
82428da3c9 Remove use of forked reference package for cli
Use resolving to repo info as the split point between the
legitimate reference package and forked reference package.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: bbc4ac69fa
Component: cli
2017-01-19 16:04:50 -08:00
2603252d3d Merge pull request #28925 from daehyeok/ineffassign
Refactoring ineffectual assignments
Upstream-commit: d9c0b0b8ef
Component: cli
2017-01-18 15:01:57 +01:00
159f204ae9 purify error message in cli for create and run command
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: b554a5f625
Component: cli
2017-01-17 17:21:17 +08:00
1daa5daff5 Add version annotation to various flags added in 1.13
Pull request https://github.com/docker/docker/pull/27745 added support for the
client to talk to older versions of the daemon. Various flags were added to
docker 1.13 that are not compatible with older daemons.

This PR adds annotations to those flags, so that they are automatically hidden
if the daemon is older than docker 1.13 (API 1.25).

Not all new flags affect the API (some are client-side only). The following
PR's added new flags to docker 1.13 that affect the API;

- https://github.com/docker/docker/pull/23430 added `--cpu-rt-period`and `--cpu-rt-runtime`
- https://github.com/docker/docker/pull/27800 / https://github.com/docker/docker/pull/25317 added `--group` / `--group-add` / `--group-rm`
- https://github.com/docker/docker/pull/27702 added `--network` to `docker build`
- https://github.com/docker/docker/pull/25962 added `--attachable` to `docker network create`
- https://github.com/docker/docker/pull/27998 added `--compose-file` to `docker stack deploy`
- https://github.com/docker/docker/pull/22566 added `--stop-timeout` to `docker run` and `docker create`
- https://github.com/docker/docker/pull/26061 added `--init` to `docker run` and `docker create`
- https://github.com/docker/docker/pull/26941 added `--init-path` to `docker run` and `docker create`
- https://github.com/docker/docker/pull/27958 added `--cpus` on `docker run` / `docker create`
- https://github.com/docker/docker/pull/27567 added `--dns`, `--dns-opt`, and `--dns-search` to `docker service create`
- https://github.com/docker/docker/pull/27596 added `--force` to `docker service update`
- https://github.com/docker/docker/pull/27857 added `--hostname` to `docker service create`
- https://github.com/docker/docker/pull/28031 added `--hosts`, `--host-add` / `--host-rm` to `docker service create` and `docker service update`
- https://github.com/docker/docker/pull/28076 added `--tty` on `docker service create` / `docker service update`
- https://github.com/docker/docker/pull/26421 added `--update-max-failure-ratio`, `--update-monitor` and `--rollback` on `docker service update`
- https://github.com/docker/docker/pull/27369 added `--health-cmd`, `--health-interval`, `--health-retries`, `--health-timeout` and `--no-healthcheck` options to `docker service create` and `docker service update`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 5d2722f83d
Component: cli
2017-01-16 18:21:20 +01:00
79ea6e48d7 Don't use AutoRemove on older daemons
Docker 1.13 moves the `--rm` flag to the daemon,
through an AutoRemove option in HostConfig.

When using API 1.24 and under, AutoRemove should not be
used, even if the daemon is version 1.13 or above and
"supports" this feature.

This patch fixes a situation where an 1.13 client,
talking to an 1.13 daemon, but using the 1.24 API
version, still set the AutoRemove property.

As a result, both the client _and_ the daemon
were attempting to remove the container, resulting
in an error:

    ERRO[0000] error removing container: Error response from daemon:
    removal of container ce0976ad22495c7cbe9487752ea32721a282164862db036b2f3377bd07461c3a
    is already in progress

In addition, the validation of conflicting options
is moved from `docker run` to `opts.parse()`, so
that conflicting options are also detected when
running `docker create` and `docker start` separately.

To resolve the issue, the `AutoRemove` option is now
always set to `false` both by the client and the
daemon, if API version 1.24 or under is used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 35de37289b
Component: cli
2017-01-15 01:59:57 +01:00
df1baac4fc Refactoring ineffectual assignments
This patch fixed below 4 types of code line
1. Remove unnecessary variable assignment
2. Use variables declaration instead of explicit initial zero value
3. Change variable name to underbar when variable not used
4. Add erro check and return for ignored error

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
Upstream-commit: 266900235c
Component: cli
2017-01-13 00:27:01 -07:00
7a6a7e6b80 Merge pull request #29226 from yongtang/28535-prune-until-follow-up
Add `--filter until=<timestamp>` for `docker container/image prune`
Upstream-commit: 39c5af4a85
Component: cli
2017-01-09 17:58:01 +01:00
058574859e Merge pull request #29688 from tronicum/since-flag
explain since format and give examples
Upstream-commit: 092eb696e9
Component: cli
2017-01-09 09:27:30 -05:00
d499070791 explain since format and give examples
Signed-off-by: tronicum <tronicum@user.github.com>
Upstream-commit: 6081f43bd1
Component: cli
2017-01-08 05:27:54 +01:00
c902dd671a Add --filter until=<timestamp> for docker container/image prune
This fix is a follow up for comment
https://github.com/docker/docker/pull/28535#issuecomment-263215225

This fix provides `--filter until=<timestamp>` for `docker container/image prune`.

This fix adds `--filter until=<timestamp>` to `docker container/image prune`
so that it is possible to specify a timestamp and prune those containers/images
that are earlier than the timestamp.

Related docs has been updated

Several integration tests have been added to cover changes.

This fix fixes #28497.

This fix is related to #28535.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: e2416af013
Component: cli
2017-01-04 14:16:42 -08:00
a1174cb059 keep network option consistent between network connect and run
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
Upstream-commit: 567b554540
Component: cli
2017-01-04 19:54:03 +08:00
1f9f54deef Merge pull request #29683 from vdemeester/runconfig-clean
Clean some stuff from runconfig that are cli only…
Upstream-commit: 2e880dd199
Component: cli
2016-12-29 17:42:08 +01:00
c38ac069ca Merge pull request #29687 from thaJeztah/cleanup-cli-command-container
Minor cleanups in cli/command/container
Upstream-commit: 734f695b29
Component: cli
2016-12-29 09:31:46 +01:00
800c425eab exit collect when we get EOF
Signed-off-by: Xianglin Gao <xlgao@zju.edu.cn>
Upstream-commit: 5860dd5f80
Component: cli
2016-12-29 13:38:30 +08:00
abab494a4f Support for docker content trust for plugins
Add integration test for docker content trust

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: fcaa89f296
Component: cli
2016-12-27 12:51:00 -08:00
f820fb530f Minor cleanups in cli/command/container
This change does some minor cleanups in the
cli/command/container package;

- sort imports
- replace `fmt.Fprintf()` with `fmt.Fprintln()` if no formatting is used
- replace `fmt.Errorf()` with `errors.New()` if no formatting is used
- remove some redundant `else`'s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: f459796896
Component: cli
2016-12-26 01:33:25 +01:00
f912773c28 Clean some stuff from runconfig that are cli only…
… or could be in `opts` package. Having `runconfig/opts` and `opts`
doesn't really make sense and make it difficult to know where to put
some code.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 6726879382
Component: cli
2016-12-24 13:16:00 +01:00
d1cd767c90 Merge pull request #29314 from vdemeester/no-more-utils
Remove the utils package
Upstream-commit: 6c1299e819
Component: cli
2016-12-22 15:21:05 +01:00
4b4fbe7e43 Merge pull request #29603 from mstanleyjones/docker_diff_improvements
Clarify what docker diff shows
Upstream-commit: ea51e6159f
Component: cli
2016-12-22 15:15:01 +01:00
618dee8851 Merge pull request #28714 from thaJeztah/move-logdriver-check-to-daemon
move check for supported drivers to daemon
Upstream-commit: 63677ef495
Component: cli
2016-12-21 13:47:30 -05:00
d11aa2f821 Clarify what docker diff shows
Signed-off-by: Misty Stanley-Jones <misty@docker.com>
Upstream-commit: 606a16a07d
Component: cli
2016-12-20 17:03:11 -08:00
2858451cf0 remove client-side for supported logging drivers
The `docker logs` command performed a
client-side check if the container's
logging driver was supported.

Now that we allow the client to connect
to both "older" and "newer" daemon versions,
this check is best done daemon-side.

This patch remove the check on the client
side, and leaves validation to the daemon,
which should be the source of truth.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 8246c49498
Component: cli
2016-12-19 14:30:01 +01:00
12d8535d84 Improve error output for docker stats ...
While looking into `docker stats <c1> <c2> ...` I noticed that
the error output is quite long, especially if there are multiple errors:
```sh
ubuntu@ubuntu:~/docker$ docker stats nofound
: Error response from daemon: No such container: nofound
ubuntu@ubuntu:~/docker$ docker stats nofound foo bar
: Error response from daemon: No such container: nofound, : Error response from daemon: No such container: foo, : Error response from daemon: No such container: bar
```

There are several issues,
1. There is an extra `: ` at the beginning. That is because if container is not found,
the name will not be available from the daemon.
2. Multiple errors are concatenated with `, ` which will be quite long.

This fix:
1. Only prient out the error from daemon.
2. Multiple errors are printed out line by line.

Below is the new output:
```sh
ubuntu@ubuntu:~/docker$ docker stats nofound
Error response from daemon: No such container: nofound
ubuntu@ubuntu:~/docker$ docker stats nofound foo bar
Error response from daemon: No such container: nofound
Error response from daemon: No such container: foo
Error response from daemon: No such container: bar
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: c6b3fcbe32
Component: cli
2016-12-17 16:51:11 -08:00
8f86ac53c1 Move templates to pkg/templates
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 26fca512dd
Component: cli
2016-12-12 09:34:03 +01:00
b4cfb614da Convert DanglingOnly to Filters for docker image prune
This fix convert DanglingOnly in ImagesPruneConfig to Filters,
so that it is possible to maintain API compatibility in the future.

Several integration tests have been added to cover changes.

This fix is related to 28497.

A follow up to this PR will be done once this PR is merged.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: dd39897fca
Component: cli
2016-12-02 20:08:49 -08:00