New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker PS filter by ancestor image does not match tagged images if image tag is omitted from filter #24295
Comments
This is most likely because your Situation 1 ( $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 16.04 cf62323fa025 5 days ago 125 MB
....
ubuntu latest c5f1cf30c96b 10 weeks ago 120.8 MB $ docker run -dit ubuntu:16.04
ef296d58096d187c61ba2725b3f6064d0731c9d2e808bd49bc0e64a233ddd97a
$docker ps --filter=ancestor=ubuntu:16.04
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef296d58096d ubuntu:16.04 "/bin/bash" 10 seconds ago Up 9 seconds prickly_lichterman
$ docker ps --filter=ancestor=ubuntu
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES However, after updating the $ docker pull ubuntu:latest
latest: Pulling from library/ubuntu
Digest: sha256:ba1688fec34f66d8a7ff5b42e6971625d8232c72bf0e38ad06dda10cad157293
Status: Downloaded newer image for ubuntu:latest $docker ps --filter=ancestor=ubuntu:16.04
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef296d58096d ubuntu:16.04 "/bin/bash" 10 seconds ago Up 9 seconds prickly_lichterman
$ docker ps --filter=ancestor=ubuntu
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef296d58096d ubuntu:16.04 "/bin/bash" 34 seconds ago Up 33 seconds prickly_lichterman As far as I can see, there's no bug, so I'm closing this, but feel free to comment after I closed |
Hi @thaJeztah, I had incorrectly assumed that omitting the tag from the filter would return all containers using that image with any tag. I have confirmed since that the documentation does indeed state this, but I missed it. It would, however, be a very useful feature to be able to filter for all containers based on a named image with any tag variant, something like:
Thanks for your time. |
Excuse me, but how is this not a bug?
Why does it work after updating the latest image? Is it documented anywhere? How is this logical that it should NOT work if the "latest" image is not present on the machine? Maybe I remove the "latest" image tomorrow, does it mean all my scripts should stop working? and you call this a feature not a bug? I've experienced a tremendous amount of frustration trying to figure this out. At the very least, this should be clearly documented. Thank you in advance for taking another look at it. |
Hi Sebastiaan @thaJeztah, The solution is not working for me, unfortunately. I have the latest image (freshly pulled):
The 0.15.1 image is running:
The filter command with a tag works:
The filter command without a tag still doesn't work:
Please help. |
Does the Perhaps instead of using the default |
Good question! Ideally I would think that it should support a wildcard for the tag. But the whole "ancestor" thing is fuzzy, because you're right, it could be based on which image was pulled first and then what layers were added later. But all we need is just a "simple" text search. For context, what I'm trying to do is make sure I stop all instances of certain containers to free up the ports. So in a script I have lines like:
I could of course do some grep magic but I would have thought that it should be doable with a straight docker command. Perhaps there are other solutions I'm not thinking of? Update: the difficulty with grep is that I also have some containers running in kubernetes that I don't want to touch. They are based on custom images but would also match for nats-streaming (in this case). So filtering the running containers by their underlying image would work, but the grep search might find all the images, including the kubernetes ones. |
When working with your own images, best workaround I found is to filter by label, provided that all your images have a common one (easy to add). Example in your docker file (or use the
Then match containers running with this image with :
Of course this doesn't work for upstream images, if it's the case may want to inspect them and see if they share a label you could use for filter. |
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Ubuntu 14.04 running inside Virtualbox 5
Steps to reproduce the issue:
docker run --detach ubuntu:16.04 /bin/sh -c 'sleep 86400'
docker ps --filter=ancestor=ubuntu:16.04
docker ps --filter=ancestor=ubuntu
Describe the results you received:
Step 2 returned the newly started container.
Step 3 returned no results.
Describe the results you expected:
Step 3 should have returned the same container as Step 2 did.
Or at the very least there should be a syntax for filtering by ancestor which allows matching on image name with varying tags. The documentation suggests this is possible by defining the
:tag
component of the ancestor image filter as optional.Additional information you deem important (e.g. issue happens only occasionally):
Repeatable every time.
The text was updated successfully, but these errors were encountered: