Fix docker ps --filter publish#40442
Conversation
cf3076c to
a5bb08a
Compare
|
Can't complete tests on my machine because of #40237 |
oh! Hm, I should check if I run into the same issue on my setup. I usually use the make DOCKER_GRAPHDRIVER=vfs TEST_FILTER='TestBuildPreserveXattrs' test-integrationThanks for working on this! I'll have a look at the changes you made so far. I'll probably ask you to squash (some of) your commits before we merge |
Thanks for the tip! Nevertheless, I was able to execute the suite and The test suite seemed to work, although the pipeline failed. If I can work on improving something more tell me. |
daemon/list.go
Outdated
There was a problem hiding this comment.
Given that port.PublicPort and port.PrivatePort are already an integer; wondering if we should skip the nat.NewPort (which parses the port string back into an integer), and instead just;
publishedPort = nat.Port(fmt.Sprintf("%d/%s", port.PublicPort, port.Type))
exposedPort = nat.Port(fmt.Sprintf("%d/%s", port.PrivatePort, port.Type))There was a problem hiding this comment.
started reviewing, but got sidetracked ^ let me post the above at least for now (I'll try having a closer look tomorrow)
|
Hi @thaJeztah do I need to do something more on this PR? |
|
@thaJeztah PTAL |
thaJeztah
left a comment
There was a problem hiding this comment.
thanks! sorry for the delay (again)
code LGTM. I see it needs a "squash" (there's seven commits in the PR, looks like we can squash them to a single one).
Let me do a quick rebase and squash of those commits, then we can merge once CI has run
daemon/list.go
Outdated
There was a problem hiding this comment.
looks like we don't need the else here (as we'll exit the loop if the publishedPort above matches), in which case we could even omit the publishedPort / exposedPort variables.
I might be doing some cleaning up of this code in general, so no need to change
- Add tests to ensure it's working - Rename variables for better clarification - Fix validation test - Remove wrong filter assertion based on publish filter - Change port on test Signed-off-by: Jaime Cepeda <[email protected]>
95136b7 to
f48b7d6
Compare
|
Thanks @thaJeztah ! if you need some help on my side please tell me |
|
I think we should be good to go (praying to the CI gods to give us "green") 👍 |
|
All green! Here we go 🎉 |
|
Thank you! |
|
i'm not sure, but i think this fix causes an issues with ports which are mapped directly on the host, e.g; ports:
- target: 3306
published: 3306
protocol: tcp
mode: hoston machines running docker 19.X i can do this with services deployed in host mode; on hosts running docker 20.X i get no output, while i'm certain the port is exposed; "HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "host",
"PortBindings": {
"3306/tcp": [
{
"HostIp": "",
"HostPort": "3306"
}
]
},
} |
|
I'm also seeing an issue. In version 19.03.x, filter on exposed/published ports work for running & stopped containers Starting with docker version 20.10.x, only running containers are reported for the filter. |
- What I did
Fixed the filter on published ports when using the command
docker ps --filter publish- How I did it
I checked on
PublicPortvalue insidecontainer.Portsinstead oftypes.Snapshot.PublishedPorts.I also did the same on
--filter expose. I checked onPrivatePortinstead ontypes.Snapshot.ExposedPorts- How to verify it
I followed the same steps like #40405
First, create some test containers:
Now, if you filter on publish ports:
We can find that the filter is applied successfully
- Description for the changelog
fix filter on
docker ps --filter publish. Also changedocker ps --filter expose- A picture of a cute animal (not mandatory but encouraged)
Fixes #40405