result:
```yaml
services:
myservice:
# ...
command: python otherapp.py
```
- For the multi-value options `ports`, `expose`, `external_links`, `dns`, `dns_search`, and `tmpfs`, Compose concatenates both sets of values:
original service:
```yaml
services:
myservice:
# ...
expose:
- "3000"
```
local service:
```yaml
services:
myservice:
# ...
expose:
- "4000"
- "5000"
```
result:
```yaml
services:
myservice:
# ...
expose:
- "3000"
- "4000"
- "5000"
```
- In the case of `environment`, `labels`, `volumes`, and `devices`, Compose "merges" entries together with locally defined values taking precedence. For `environment` and `labels`, the environment variable or label name determines which value is used:
original service:
```yaml
services:
myservice:
# ...
environment:
- FOO=original
- BAR=original
```
local service:
```yaml
services:
myservice:
# ...
environment:
- BAR=local
- BAZ=local
```
result:
```yaml
services:
myservice:
# ...
environment:
- FOO=original
- BAR=local
- BAZ=local
```
- Entries for `volumes` and `devices` are merged using the mount path in the container:
original service:
```yaml
services:
myservice:
# ...
volumes:
- ./original:/foo
- ./original:/bar
```
local service:
```yaml
services:
myservice:
# ...
volumes:
- ./local:/bar
- ./local:/baz
```
result:
```yaml
services:
myservice:
# ...
volumes:
- ./original:/foo
- ./local:/bar
- ./local:/baz
```
For more merging rules, see [Merge and override](/reference/compose-file/merge.md) in the Compose Specification.
### Additional information
- Using `-f` is optional. If not provided, Compose searches the working directory and its parent directories for a `compose.yaml` and a `compose.override.yaml` file. You must supply at least the `compose.yaml` file. If both files exist on the same directory level, Compose combines them into a single configuration.
- You can use a `-f` with `-` (dash) as the filename to read the configuration from `stdin`. For example:
```console
$ docker compose -f - <<EOF
webapp:
image: examples/web
ports:
- "8000:8000"
volumes:
- "/data"
environment:
- DEBUG=1
EOF
```
When `stdin` is used, all paths in the configuration are relative to the current working directory.
- You can use the `-f` flag to specify a path to a Compose file that is not located in the current directory, either from the command line or by setting up a [COMPOSE_FILE environment variable](../environment-variables/envvars.md#compose_file) in your shell or in an environment file.
For example, if you are running the [Compose Rails sample](https://github.com/docker/awesome-compose/tree/master/official-documentation-samples/rails/README.md), and have a `compose.yaml` file in a directory called `sandbox/rails`. You can use a command like [docker compose pull](/reference/cli/docker/compose/pull.md) to get the postgres image for the `db` service from anywhere by using the `-f` flag as follows: `docker compose -f ~/sandbox/rails/compose.yaml pull db`