Add publish and expose filter for docker ps --filter#27557
Add publish and expose filter for docker ps --filter#27557vdemeester merged 1 commit intomoby:masterfrom
publish and expose filter for docker ps --filter#27557Conversation
|
Design SGTM 👼 |
daemon/list.go
Outdated
There was a problem hiding this comment.
I wonder why it's never returning error
There was a problem hiding this comment.
Thanks @LK4D4. I wasn't sure initially as some of the other filters didn't return the error. The PR has been updated and now expose and publish will return error.
|
@yongtang would you mind to rebase? Thanks! |
143e04b to
07ccfde
Compare
|
Thanks @LK4D4 for the review. The PR has been updated and rebased. Please take a look and let me know if there are any issues. |
07ccfde to
902335e
Compare
There was a problem hiding this comment.
nit: you could add -q and use checker.Equals instead
mlaventure
left a comment
There was a problem hiding this comment.
LGTM with inconsequential nit
|
ping @LK4D4 |
902335e to
91e1432
Compare
|
Thanks all for the review. The PR has been updated. Please take a look and let me know if there are any other issues. |
vdemeester
left a comment
There was a problem hiding this comment.
SGTM but I feel the logrus.Errorf shouldn't be there 👼
daemon/list.go
Outdated
There was a problem hiding this comment.
My bad. How could I have missed this one? 😳
91e1432 to
a548a44
Compare
|
Thanks @vdemeester. The PR has been updated. |
a548a44 to
3257ff7
Compare
vdemeester
left a comment
There was a problem hiding this comment.
LGTM 🐸
/cc @thaJeztah for docs review 👼
|
ping @thaJeztah |
docs/reference/commandline/ps.md
Outdated
There was a problem hiding this comment.
port is 80, protocol is tcp
There was a problem hiding this comment.
@AkihiroSuda The PR has been updated. Thanks.
3257ff7 to
4ba69bd
Compare
|
@yongtang needs rebase |
This fix tries to address the enhancement proposal raised in 27178 for filtering based on published or exposed ports of `docker ps --filter`. In this fix, two filter options, `publish` and `expose` have been added to take either `<port>[/<protocol>]` or `<from>-<to>[/<protocol>]` and filtering on containers. An integration test has been added to cover the changes. This fix fixes 27178. Signed-off-by: Yong Tang <[email protected]>
4ba69bd to
743943f
Compare
|
@LK4D4 @thaJeztah The PR has been rebased. Thanks. |
vdemeester
left a comment
There was a problem hiding this comment.
docs LGTM
/cc @thaJeztah for revisit 👼
|
@yongtang can you;
|
|
Thanks @thaJeztah. A PR #30661 has been created for the API history and man page. Please take a look. |
This fix updates API history and man page for `docker ps --filter expose/publish`, from the feedback: moby#27557 (comment) Signed-off-by: Yong Tang <[email protected]>
This fix updates API history and man page for `docker ps --filter expose/publish`, from the feedback: moby/moby#27557 (comment) Signed-off-by: Yong Tang <[email protected]>
This fix updates API history and man page for `docker ps --filter expose/publish`, from the feedback: moby/moby#27557 (comment) Signed-off-by: Yong Tang <[email protected]> Upstream-commit: d77db0bd9ac80a3a2e7ad4d90b6aa33fe4fc0462 Component: cli
This fix updates API history and man page for `docker ps --filter expose/publish`, from the feedback: moby/moby#27557 (comment) Signed-off-by: Yong Tang <[email protected]>
|
It doesn't work for me( I can filter only port to, not from |
|
Yes, something looks to be off. Create some containers; docker run -d --name test_no_ports nginx:alpine
docker run -d --name test_port_1080 -p 1080:80 nginx:alpine
docker run -d --name test_port_1090 -p 1090:80 nginx:alpine
docker run -d --name test_port_80_random -p 80 nginx:alpine
docker run -d --name test_port_all_random -P nginx:alpine
docker ps --filter name=test_
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3ce8232cdd04 nginx:alpine "nginx -g 'daemon of…" 6 seconds ago Up 6 seconds 0.0.0.0:32775->80/tcp test_port_all_random
7f8fad7a0eb9 nginx:alpine "nginx -g 'daemon of…" 7 seconds ago Up 6 seconds 0.0.0.0:32774->80/tcp test_port_80_random
3870ccc2f8f7 nginx:alpine "nginx -g 'daemon of…" 7 seconds ago Up 6 seconds 0.0.0.0:1090->80/tcp test_port_1090
aa565211513e nginx:alpine "nginx -g 'daemon of…" 8 seconds ago Up 7 seconds 0.0.0.0:1080->80/tcp test_port_1080
c4a1c6e0e99b nginx:alpine "nginx -g 'daemon of…" 8 seconds ago Up 7 seconds 80/tcp test_no_portsFiltering on the "exposed" port works: docker ps --filter name=test_ --filter expose=80
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3ce8232cdd04 nginx:alpine "nginx -g 'daemon of…" 20 seconds ago Up 19 seconds 0.0.0.0:32775->80/tcp test_port_all_random
7f8fad7a0eb9 nginx:alpine "nginx -g 'daemon of…" 21 seconds ago Up 20 seconds 0.0.0.0:32774->80/tcp test_port_80_random
3870ccc2f8f7 nginx:alpine "nginx -g 'daemon of…" 21 seconds ago Up 20 seconds 0.0.0.0:1090->80/tcp test_port_1090
aa565211513e nginx:alpine "nginx -g 'daemon of…" 22 seconds ago Up 20 seconds 0.0.0.0:1080->80/tcp test_port_1080
c4a1c6e0e99b nginx:alpine "nginx -g 'daemon of…" 22 seconds ago Up 21 seconds 80/tcp test_no_ports
docker ps --filter name=test_ --filter expose=90
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESFiltering on the "published" port doesn't (trying some variations below): docker ps --filter name=test_ --filter publish=1080
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAME
docker ps --filter name=test_ --filter publish=1080/tcp
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker ps --filter name=test_ --filter publish=1080/udp
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESHowever, using the "exposed" port number instead of the "published" port shows some results: docker ps --filter name=test_ --filter publish=80
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f8fad7a0eb9 nginx:alpine "nginx -g 'daemon of…" About a minute ago Up About a minute 0.0.0.0:32774->80/tcp test_port_80_random
3870ccc2f8f7 nginx:alpine "nginx -g 'daemon of…" About a minute ago Up About a minute 0.0.0.0:1090->80/tcp test_port_1090
aa565211513e nginx:alpine "nginx -g 'daemon of…" About a minute ago Up About a minute 0.0.0.0:1080->80/tcp test_port_1080It appears it's filtering on the wrong value; also, the container with "random" port-mapping for all ports is missing in this case (perhaps it's filtering on ports that were explicitly configured to be published?) Note that the docker run -d --publish 80 busybox top
537c87330e660cc4d7a7426dcddd771a3b1bb3f7c21c7750a4b1a3358e976b1c
docker ps --filter publish=80
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
537c87330e66 busybox "top" 19 seconds ago Up 18 seconds 0.0.0.0:32776->80/tcp sleepy_khorana
... |
|
opened #40405 |
Reuse existing structures and rely on json serialization to deep copy Container objects. Also consolidate all "save" operations on container.CheckpointTo, which now both saves a serialized json to disk, and replicates state to the ACID in-memory store. Signed-off-by: Fabio Kung <[email protected]> (cherry picked from commit edad527) Signed-off-by: Kir Kolyshkin <[email protected]> Conflicts: - daemon/container_operations.go: missing moby#30117 - daemon/daemon.go: missing moby#32821 - daemon/list.go: missing moby#27557, moby#33241 etc.
- What I did
This fix tries to address the enhancement proposal raised in #27178 for filtering based on published or exposed ports of
docker ps --filter.Note: this PR didn't implement the wildcard match initially, as protocol (
tcp/udp) has to be taken into consideration. But is open to suggestions.- How I did it
In this fix, two filter options,
publishandexposehave been added to take either<port>[/<protocol>]or<from>-<to>[/<protocol>]and filtering on containers.- How to verify it
An integration test has been added to cover the changes.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
This fix fixes #27178.
Signed-off-by: Yong Tang [email protected]