Sometimes it works, sometimes it breaks, it depends on your exact version of the IDE, but most of the time it doesn't work. And I find keeping all of my docker configuration in the root of the project cluttering the project, I prefer to keep them in the deploy, docker, or compose subdirectory.
The bug for this exists for many years with absolutely nothing being done about it. Maybe it's my personal pain but it is highly annoying.
Sometimes I'm so desperate that I wish to disassemble and patch this part of the IDE myself.