# CLI Support for Non-Default and Merged docker compose files

**URL:** <https://forums.balena.io/t/cli-support-for-non-default-and-merged-docker-compose-files/372378>\
**Category:** General\
**Created:** [October 30, 2024, 3:33pm UTC](https://forums.balena.io/t/cli-support-for-non-default-and-merged-docker-compose-files/372378 "2024-10-30T15:33:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdalke-havoc](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@cdalke-havoc](https://forums.balena.io/u/cdalke-havoc)\
**Post date:** [October 30, 2024, 3:33pm UTC](https://forums.balena.io/t/cli-support-for-non-default-and-merged-docker-compose-files/372378/1 "2024-10-30T15:33:29Z")

</div>

I wanted to restart a discussion on balena-cli supporting non-default docker-compose.yml files.

### Background

For context, docker compose allows changing and merging the docker-compose filename using the `-f` flag: [docker compose | Docker Docs](https://docs.docker.com/reference/cli/docker/compose/#examples)  
This allows for two workflows:

- Specifying _multiple_ docker-compose files which are merged in order
- Specifying a _single_ docker-compose file in a different path

### Use Cases

First, to allow multiple fleets with different feature subsets to be deployed from the same source code. For example, we have two robots that are identical except that one runs computer vision on a Jetson and one does not.

We’d like to push layered files that build the config this way:

```auto
docker-compose.yml # Default, for local dev
docker-compose.prod.yml # Deployed to Balena
docker-compose.mod-cv.yml # Module which adds CV containers

```

The CV fleet would receive `balena push -f docker-compose.prod.yml -f docker-compose.mod-cv.yml`.

The non-CV fleet would receive `balena push -f docker-compose.prod.yml`.

* * *

Second, this change would allow `docker-compose.yml` to be used for local development.

Since this is the default file for docker compose, it improves developer ergonomics to have this file be configured to spin up a local environment. Compose files for Balena often have a lot of config specific to the production devices that you don’t want to run locally.

I’d guess for most teams running your code locally is \>100x more frequent than pushing a release, so this workflow should be as simple as possible (`docker compose up`).

## Proposed Solution

My proposed solution is that **balena-cli** should take in one or more `-f / --filename` arguments, specifying one or more compose files:

```auto
-f, --filename<value>
  Provide one or more alternative Compose files. Files will be merged in order.

```

This behavior should match docker compose, and will allow users to change the compose filename and merge multiple compose files.

In addition, [Add support for docker-compose dev overlay by srlowe · Pull Request #2177 · balena-io/balena-cli · GitHub](https://github.com/balena-io/balena-cli/pull/2177) would be replaced by this functionality. users who want the `docker-compose.dev.yml` functionality would use `balena push -f docker-compose.yml -f docker-compose.dev.yml` to match compose’s syntax for multiple files.

## References

I’ve created a Balena Feature Request for this: [CLI Support for Non-Default or Multiple Compose files - Feature Requests - balenaForums](https://feature-requests.balena.io/posts/152/cli-support-for-non-default-or-multiple-compose-files)

Long-running request (since 2019): [Add ability to select a docker-compose file · Issue #1142 · balena-io/balena-cli · GitHub](https://github.com/balena-io/balena-cli/issues/1142)

PR from April which is an attempt to add this: [Feat: Add ability to select a docker-compose file by quentingllmt · Pull Request #2760 · balena-io/balena-cli · GitHub](https://github.com/balena-io/balena-cli/pull/2760)
