docker / docker/cli

Auto-mappings for host paths in bind mount option

Open
#3,786 0 comments 1 reaction 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

Description

It would be nice if .docker/config.json has a configuration to convert

docker run -v /path/to/somewhere/foo:/workspace

to

docker run -v /anotherpath/foo:/workspace

automatically.

Background

My machine is Windows and I'm running a docker daemon on WSL2 distribution (Ubuntu-20.04). That's not Docker Desktop but a standard docker daemon for Ubuntu, installed following the instructions in https://docs.docker.com/engine/install/ubuntu/ .
WSL2 distribution can access Windows filesystems on /mnt/c (via SMB). That means,

docker run -v /mnt/c/Users/ikedam/Desktop/work:/workspace ...

allows launch a container accessing files on Windows. I want to launch the container from Windows with:

docker run -v "C:\\Users\\ikedam\\Desktop\\work:/workspace" ...

or:

docker run -v ".\\work:/workspace" ...

This feature allows that.

Compared to Docker Desktop

Docker Desktop (for Windows) also provides a feature to bind-mount windows filesystems.

Pros in Docker Desktop:

  • Rich UI.
  • Provides everything for docker suite. It contains not only docker daemon, but also docker cli and docker-compose cli.
  • Easy to setup. Users don't have to know about details of docker backends.
  • Docker feature gets available not only to Windows, but also to all WSL2 distributions.
  • Auto port mapping for published port to the public IP address.
    • Note: 127.0.0.1 on WSL2 is accessible also from Windows via 127.0.0.1. So this pros in Docker Desktop is only when the user wants to publish ports to a public network interface.
  • Transparent conversion between filesystems. E.g. running docker inspect on Windows outputs C:\\... for bind mounts. This feature doesn't support that.

Cons in Docker Desktop

  • Slow to start. (Maybe for GUI features?)
  • Requires updating all components to update a specific component. For example, when I want to introduce the latest docker-compose for a bug fix, I have to wait for the next release of Docker Desktop and have to update not only docker-compose but whole Docker Desktop.
  • No way to downgrade.
    • Unfortunately, new versions of Docker Desktop so often introduce new bugs, and they are often critical ones. You can't downgrade to the previous version once you upgrade to a new version. And the only way to recover your Docker Desktop is to uninstall it once and reinstall the previous one. Of course, all data in docker (images, containers, volumes) are removed.
    • Updating Docker Desktop is really risky for this reason.
    • Docker Desktop is not a open-source and developers can't fix the problem nor find a workaround by themselves.

I believe Docker Desktop is useful, but often costs too much.

Configuration example

Just like the proxies member in config.json (https://docs.docker.com/network/proxy/#configure-the-docker-client):

{
  "bindMaps": {
    "default": {
        "C:\\:/mnt/c/"
    }
  }
}

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

Start with the docker run bind-mount option and the .docker/config.json proxies configuration referenced in the issue. Trace how host paths are handled, then determine the scope and expected behavior of the proposed bindMaps setting for Windows and WSL2; done means configured mappings are applied consistently.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.