docker / docker/cli

Enhancement: Volume mode for files not directories

Open
#3,324 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/volumes kind/feature
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

If you want to mount a single config file into a container, you might use

-v $(pwd)/nginx.conf:/etc/nginx/conf.d/site.conf:ro

If nginx.conf does not exist, it will be created as a directory on the host, and probably raise an error:

Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

It would be useful if there were a way to indicate that the volume refers to a single file. For example:

-v $(pwd)/nginx.conf:/etc/nginx/conf.d/site.conf:fro
                                                 ^-- for file

In this example, :f or :frw would indicate a read-write file, and :fro would indicate read-only. If :fro is used and the file doesn't exist, it would raise an error.

There should also be corresponding syntax for VOLUME and a long syntax flag for Docker Compose files.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files, tests, or entry points are named in the issue. Trace volume-option parsing in the CLI first; completion would cover the proposed file-mode syntax, its missing-file behavior, and corresponding VOLUME and Compose forms, with tests for each.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, go
Domain
cli, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.