Hey everyone! I have a few services set up: `foobar`, `foobaz`, `barfum`, and `barqux`. I'm trying to start only the ones that start with `foo`. I've attempted using `docker compose up foo*` as well as variations like `'foo*'`, `"foo*"`, and others, but nothing seems to work. Is there a way to do this with Docker Compose? I feel like I'm not the first one with this issue. Thanks for your help!
4 Answers
Just a heads up, the globbing happens at the shell level and not within Docker. This means that patterns like `foo*` won’t match services unless they're explicitly defined. That's why your command didn't work as expected.
One alternative is to add different profiles for your services and organize them that way. It helps in managing what gets started without confusion.
Yeah, I'm using profiles for now, but it complicates my commands since I always have to specify `--profile`. It would be much easier if it only triggered specific services.
For globs to work in this context, Docker must accept multiple arguments. Unfortunately, passing `foo*` as an argument seems not to be supported. You could look into using `find` and `xargs` for starting them in sequence.
You can use this command: `docker compose up $(docker compose config --services | grep '^foo')`. It filters the services based on your pattern and starts them properly!
Exactly! Just remember that this approach uses shell features, so make sure you're comfortable with them.

I thought that might be the case since I got an error saying 'no such service: foo*'. Thanks for clarifying!