---
source: https://iinventedlight.com/library/notes/docker-compose-configs.md
title: "Docker Compose configs - mount config files into services without rebuilding the image"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker Compose file reference); Apache-2.0 (compose-spec/compose-spec (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Docker Compose file reference, Configs top-level element; compose-spec/compose-spec (GitHub), 08-configs.md. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/compose-spec/compose-spec/main/LICENSE). Copyright The Compose Specification Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker compose configs"
tags: [docker, compose, configs, configuration, containers]
client: Librarian
sources:
  - id: S1
    title: "Configs top-level element"
    publisher: Docker Compose file reference
    url: https://docs.docker.com/reference/compose-file/configs/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "08-configs.md"
    publisher: compose-spec/compose-spec (GitHub)
    url: https://github.com/compose-spec/compose-spec/blob/main/08-configs.md
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# Docker Compose configs - mount config files into services without rebuilding the image
**Answer:** Declare the config under the top-level `configs` element (from a `file`, `environment`, inline `content`, or `external`), then grant it in the service's `configs` list. Configs let services adapt their behaviour without the need to rebuild a Docker image, and are mounted as files at `/<config-name>` by default.

## Example

```yaml
services:
  web:
    image: httpd:latest
    configs:
      - http_config
      - app_config
configs:
  http_config:
    file: ./httpd.conf
  app_config:
    content: |
      debug=${DEBUG}
      spring.application.name=${COMPOSE_PROJECT_NAME}
  simple_config:
    environment: "SIMPLE_CONFIG_VALUE"
  shared_config:
    external: true
    name: "${HTTP_CONFIG_KEY}"
```

## Sources

| Source | Content |
|---|---|
| `file` | the contents of the file at the specified path |
| `environment` | the value of an environment variable (Compose 2.23.1+) |
| `content` | the inlined value, with variables interpolated (Compose 2.23.1+) |
| `external: true` | a config that has already been created; Compose does not attempt to create it |

## Defaults and rules

- Services can only access configs when explicitly granted by a `configs` attribute.
- Linux containers mount it at `/<config-name>`; Windows containers use `C:\<config-name>`.
- By default the config is owned by the user running the container command and has world-readable permissions (mode 0444), unless the service overrides this.
- When deployed, `http_config` is created as `<project_name>_http_config`.
- `name` sets the object name to look up in the container engine; it is used as is and will not be scoped with the project name.
- If `external` is set to `true`, all other attributes apart from `name` are irrelevant, and any other attribute makes Compose reject the file as invalid.
- An external config that does not exist causes an error.

## See also

- [docker-compose-secrets](https://iinventedlight.com/library/notes/docker-compose-secrets/)
- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)
- [kubernetes-configmaps](https://iinventedlight.com/library/notes/kubernetes-configmaps/)

## Claims

- id: C1
  claim: Configs avoid rebuilding the Docker image.
  source: S1
  evidence: "Configs let services adapt their behaviour without the need to rebuild a Docker image."

- id: C2
  claim: Configs default to mode 0444.
  source: S1
  evidence: "Has world-readable permissions (mode 0444)"

- id: C3
  claim: Config names are not scoped with the project name.
  source: S2
  evidence: "will **not** be scoped with the project name."

## Sources

- [S1] Configs top-level element. Docker Compose file reference. https://docs.docker.com/reference/compose-file/configs/ . License: Apache-2.0. Accessed 2026-11-18.

- [S2] 08-configs.md. compose-spec/compose-spec (GitHub). https://github.com/compose-spec/compose-spec/blob/main/08-configs.md . License: Apache-2.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker Compose file reference, Configs top-level element; compose-spec/compose-spec (GitHub), 08-configs.md. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Apache-2.0 (https://raw.githubusercontent.com/compose-spec/compose-spec/main/LICENSE). Copyright The Compose Specification Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
