Please, don’t let people start guessing what your problem is. If you have an implementation that doesn’t work, show that in a Dockerfile for example. Any small detail could be important.
But… my guess is that the special wildcard is supported by bash and when you run the command in a Dockerfile, you have no bash shell. The default shell is usually “sh”. If the image has bash, you can change it with the SHELL instruction
SHELL ["/bin/bash", "-c"]
Then the next RUN instructions will use the bash shell.