Docker Compose
Compose service bind mounts
Map a reviewed host directory into a container. The long form can prohibit creation of a missing source using bind.create_host_path: false. Read-only prevents ordinary container writes but not host edits; target contents may be obscured. Relative sources are intended for local deployments. Check platform behavior and permissions. Inspect read-only metadata and unchanged file content after a negative write probe.
Formal Syntax & Structure
docker syntaxdocker
services.SERVICE.volumes: [{type: bind, source: PATH, target: PATH, read_only: true}]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| source | string | Reviewed source path |
| target | string | Container path |
| read_only | string | Boolean mount setting |
Working Example
Example Snippetdocker
volumes: - type: bind source: ./src target: /source read_only: true bind: create_host_path: false