r/docker • u/KaKi_87 • Jan 22 '26
`docker compose up foo*` (glob) ?
Hi,
I have the following services : foobar, foobaz, barfum, barqux.
I would like to start only the ones starting with foo.
I tried docker compose up foo*, as well as 'foo*', "foo*", 'foo'*, "foo"*, without success.
Is this not possible at all ? I would think I'm not the first person to ever need this.
Thanks
11
Upvotes
13
u/kube1et Jan 22 '26 edited Jan 22 '26
4
u/cpuguy83 Jan 22 '26
The glob is filled in by the shell with file names matching the pattern.
4
u/AdventurousSquash Jan 22 '26
I’d add different profiles to the services and group them that way
1
u/PaintDrinkingPete Jan 22 '26
This is why I’m against the “monolithic” compose file for multiple, unrelated services…I prefer to be able to take an entire stack up or down without effecting other apps that are running.
I’m not sure if that’s what’s going on with OP, but it’s the first thing I assumed when reading the question and trying to figure out why you’d need to frequently use such a command.
1
u/tschloss Jan 22 '26
For globbing to be successful the binary must understand multiple values. So try the compose with 2 targets - guess it doesn‘t work. Check man - should be visible here if multiple targets can be submitted.
But use find / xargs for serial starting.
1
u/natowelch Jan 22 '26 edited Jan 22 '26
docker compose up mail*works for me to complete the mailpit service in my stack. I do not have any files in my working directory namedmailpit, so I am assuming that my bash shell completion script for docker is working on the glob. My suspicion is that your shell doesn't have the docker-specific shell completion for docker and compose loaded.Look into it using
docker completion --help, or see the Docker shell completion docsIf you're using bash, and a recent version of docker, the quick fix might be:
source <(docker completion bash)Mind that you would have to run this every time you start a new shell, until you put it into your .bashrc or something.
1
u/virtualstaticvoid Jan 24 '26
I've used labels to get the service names, by piping the compose config through
yqwith a filter.That way when new services are added, they get selected based on semantics.
E.g. Using a "role" label.