Commit graph

77 commits

Author SHA1 Message Date
Sebastiaan van Stijn
7c46ba02e6
add support for filtering by network ID
This adds support for filtering by network ID, to be
consistent with other filter options.

Note that only *full* matches are returned; this is
consistent with other filters (e.g. volume), that
also return full matches only.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-06-07 16:50:31 +02:00
Sainath Grandhi
912af1ae8f Adding network filter to docker ps command
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
2016-06-07 16:43:11 +02:00
Paulo Ribeiro
55cdb6dcd0
Add a check for size field in custom format string
This fix addresses an issue where including the `{{.Size}}` format
field in conjunction with `docker ps --format`, without the `--size`
flag, would not correctly display the size of containers.

This is done by doing a check on the custom format string, and setting
the size flag on the options struct if the field is found. This struct
gets passed to the engine API which then generates the correct query.

An integration test is included which runs `docker ps --format "table
{{.Size}}"` without `--size`, and checks that the returned output is
not `0 B`.

Fixes #21991

As suggested by @cpuguy83, a parser is implemented to process the format
string as a template, and then traverses the template tree to determine
if `.Size` was called.

This was then reworked by making use of template execution with a
pre-processor struct that will set the `--size` option if the template
calls for the field.

The pre-processor now also sets a boolean in the context passed to the
writer. There is an integration test for this that calls `docker ps
--size --format "{{.Size}}"` and then checks that `size: {{.Size}}` is
not appended, as it would with previous behavior.

Finally, a change was made to the formatter to not automatically
add a `{{.Size}}` if a custom format is provided.

Signed-off-by: Paulo Ribeiro <paigr.io@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-06-03 21:59:10 +02:00
Yong Tang
4455ec14b8 Remove deprecated -f flag on docker tag
The -f flag on docker tag has been deprecated in docker 1.10 and
is expected to be removed in docker 1.12.

This fix removed the -f flag on docker tag and also updated
deprecated.md.

NOTE: A separate pull request for engine-api has been opened to
cover the related changes.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-06-01 09:44:25 -07:00
Antonio Murdaca
bdb354f19b TestPsGroupPortRange: allocate less ports
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-17 12:23:37 +02:00
Wen Cheng Ma
91b7157064 Deprecated of docker ps since and before options for v1.12
Deprecated note https://github.com/docker/docker/blob/master/docs/deprecated.md#docker-ps-before-and-since-options

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2016-04-19 18:13:55 +08:00
Victor Vieux
68ade49ada do not trim one char from {{.Names}} each time it is used in --format
Signed-off-by: Victor Vieux <vieux@docker.com>
2016-04-06 11:04:13 -07:00
Kenfe-Mickael Laventure
cdd7fddfec Update TestPsShowMounts to also test bind mounts
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-03-17 15:43:32 -07:00
Kai Qiang Wu(Kennan)
8a90e8a19b Add check about filter name for containers
Fixes: #21202
We add valid check about filters like network, images,
volumes did.

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
2016-03-16 03:53:40 +00:00
Darren Stahl
ad7398e664 Reenabled TestPsListContainers* tests and increased sleep time
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-03-04 10:53:04 -08:00
John Howard
9af22098af Windows CI: Temporarily disable TestPsListContainers*
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-03-02 20:43:16 -08:00
Vincent Demeester
9eb4575f8c Merge pull request #20480 from wenchma/20431-filter_since_before
Enhancement of docker ps before and since filters
2016-02-29 20:57:43 +01:00
Antonio Murdaca
e44689139d integration-cli: remove not necessary -d again
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-02-28 13:48:15 +01:00
Wen Cheng Ma
bc72883fe1 Enhancement of docker ps before and since filters
This enhancement is to fix the wrong list results on
`docker ps` before and since filters specifying the non-running container.

Fixes issue #20431

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2016-02-25 16:58:31 +08:00
David Calavera
bd4fb00fb6 Add mounts to docker ps.
- Allow to filter containers by volume with `--filter volume=name` and `filter volume=/dest`.
- Show their names in the list with the custom format `{{ .Mounts }}`.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-23 12:10:24 -05:00
Vincent Demeester
b41dba58a0 Fix the since and before filter behavior
Filters should not include stopped container if `-a` is not specified.
Right now, before and since filter are acting as --before and --since
deprecated flags. This commit is fixing that.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-02-09 09:26:20 +01:00
John Howard
2ebcb48cf1 Windows CI: TP4 reliability hack
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-01 18:02:57 -08:00
John Howard
59f4369f1a Windows CI: Turn off unreliable TP4 tests
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-01-31 15:51:56 -08:00
Zhang Wei
62a856e912 Assert error in body of function inspectField*
1. Replace raw `docker inspect -f xxx` with `inspectField`, to make code
cleaner and more consistent
2. assert the error in function `inspectField*` so we don't need to
assert the return value of it every time, this will make inspect easier.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-01-29 23:39:07 +08:00
Arnaud Porterie
777ee34b07 Factorize sleeping containers
Add `runSleepingContainer` and `runSleepingContainerInImage` helper
functions to factor out the way to run system-specific idle containers.

Define a sleeping container as command `top` in image `busybox` for
Unix and as command `sleep 60` in image `busybox` for Windows. Provide a
single point of code to update those.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2016-01-27 08:48:08 -08:00
John Howard
916b9db71d Windows CI: Darn it, I broke due to multiple declarations
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-01-26 19:58:53 -08:00
John Howard
75d107451a Windows CI: Address simple failures in TestPS*
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-01-23 16:33:45 -08:00
John Howard
845dc1b24c Windows: TestPsNotShowPortsOfStoppedContainer linux only
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-01-21 18:48:21 -08:00
Lei Jitang
6025517b68 Fix #19477, clean up the ports when release network
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-01-20 20:09:11 -05:00
Vincent Demeester
34a3c3cacf Add --format support to images command
- rename `api/client/ps` to `api/client/formatter`
- add a a image formatter

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-12-21 17:38:07 +01:00
Wen Cheng Ma
1921c62938 Re-implement --before and --since as options for --filter
* This commit will mark --before and --since as deprecated, but leave their behavior
  unchanged until they are removed, then re-implement them as options for --filter.

* And update the related docs.

* Update the integration tests.

Fixes issue #17716

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2015-11-20 13:10:13 +08:00
David Calavera
2a07b19fd8 Test that paused containers show up filtering by status.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-11-19 14:32:25 -05:00
Antonio Murdaca
7929888214 Remove deprecated cli flags
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2015-11-15 10:40:01 +01:00
Zhang Kun
83b03b0057 add c.Assert in docker_cli_ps_test.go
Signed-off-by: Zhang Kun <zkazure@gmail.com>
2015-11-04 17:29:25 +08:00
John Howard
f9a3558a9d Windows: Get Integration CLI running
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-09-04 12:32:40 -07:00
David Calavera
06699f73fb Refactor daemon container list.
Separate container iteration, filtering and reducing.
This will make easier in the future to improve the implementation of
docker ps as we know it.

The end goal is to unify the objects returned by the api for docker ps
and docker inspect, leaving all docker ps transformations to the client.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-08-31 04:24:08 -04:00
Vincent Demeester
c1af0ac082 Add 'ancestor' ps filter for image
Makes it possible to filter containers by image, using
--filter=ancestor=busybox and get all the container running busybox
image and image based on busybox (to the bottom).

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-08-26 22:59:48 +02:00
Travis Thieman
2167f40a76 Use image ID if tag has been updated
Fixes #12595

Signed-off-by: Travis Thieman <travis.thieman@gmail.com>
2015-08-23 12:11:24 -04:00
Brian Goff
5929502b4e Merge pull request #15412 from vdemeester/dont-sleep-too-much
time.Sleep in integration tests — comment and waitRun/waitInspect
2015-08-21 20:43:55 -04:00
Vincent Demeester
799d9605d6 Remove/Comment time.Sleep in integration tests
Remove what seems unnecessary time.Sleep (1 second even) and comment the
ones that seemed necessary.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-08-18 20:36:08 +02:00
David Calavera
df46bfdd4d Fix ignore -q flag in docker ps when there is a default format.
Docker ps default format should not take precedence over cli flags.
This happens effectively for other flags except `-q`.
We need to let the cli to set the format as table to print the
expected output with `-q`.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-08-17 10:48:04 -07:00
Brian Goff
693ba98cb9 Don't pass check.C to dockerCmdWithError
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-07-27 14:33:32 -04:00
Tianon Gravi
f57fc03e3b Fix "docker ps" with no containers regression
The header row was not being printed when "docker ps" was invoked without containers thanks to the new format support, and we instead received a single blank line.

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
2015-07-23 13:23:24 -07:00
Phil Estes
542b58d8f7 ps --format: Add config.js doc, fix gofmt, add integration tests
Re-add the docs from @calavera's PR to the moved cli cmd reference docs.
Fix gofmt and vet issues from carried commits
Add integration test for using format with --no-trunc and multi-names
Fix custom_test map order dependency on expected value check
Add docs to reference/commandline/ps.md
Remove "-F" flag option from original carried PR content

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-07-22 12:51:16 -04:00
Vincent Demeester
5c295460da Use dockerCmd when possible (#14603)
- integration-cli/docker_cli_attach_test.go
- integration-cli/docker_cli_attach_unix_test.go
- integration-cli/docker_cli_build_test.go
- integration-cli/docker_cli_build_unix_test.go
- integration-cli/docker_cli_by_digest_test.go
- integration-cli/docker_cli_commit_test.go
- integration-cli/docker_cli_config_test.go
- integration-cli/docker_cli_cp_test.go
- integration-cli/docker_cli_create_test.go
- integration-cli/docker_cli_pause_test.go
- integration-cli/docker_cli_port_test.go
- integration-cli/docker_cli_port_unix_test.go
- integration-cli/docker_cli_proxy_test.go
- integration-cli/docker_cli_ps_test.go
- integration-cli/docker_cli_pull_test.go
- integration-cli/docker_cli_push_test.go

- docker_api_attach_test.go
- docker_api_containers_test.go
- docker_api_events_test.go
- docker_api_exec_resize_test.go
- docker_api_exec_test.go
- docker_api_images_test.go
- docker_api_info_test.go

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-07-14 21:52:43 +02:00
John Howard
7bf26d44b0 Validate status= filter to docker ps
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-07-02 16:12:42 -07:00
David Calavera
6c42b3947a Merge pull request #12838 from fntlnz/test-cmd
Using dockerCmd when possible
2015-06-02 14:12:22 -07:00
Doug Davis
dc697b1c9f Add a "Created" state for new containers that haven't been run yet
Closes #13353

Signed-off-by: Doug Davis <dug@us.ibm.com>
2015-05-30 07:48:46 -07:00
Lei Jitang
d0de2b1e2f Make docker ps --size show virtual size really work
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-05-21 08:57:11 +08:00
Lorenzo Fontana
a2787469ac Using dockerCmd when possible
Signed-off-by: Lorenzo Fontana <fontanalorenzo@me.com>
2015-05-19 20:33:59 +02:00
Antonio Murdaca
4203230cbb c.Fatal won't fail and exit test inside a goroutine, errors should be handled outside with a channel
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-04-29 17:02:22 +02:00
David Mackey
3941623fbc trivial: typo cleanup
Signed-off-by: David Mackey <tdmackey@booleanhaiku.com>
2015-04-27 13:35:08 -07:00
Alexander Morozov
a9688cdca5 Implement teardown removeAllImages
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-04-24 10:37:21 -07:00
Antonio Murdaca
ee7a7b07e7 Remove deleteAllContainers call in test
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-04-23 16:32:50 +02:00
Alexander Morozov
dc944ea7e4 Use suite for integration-cli
It prints test name and duration for each test.
Also performs deleteAllContainers after each test.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-04-21 10:28:52 -07:00