Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What I did
This change allows host paths in bind mounts specified in
docker
command line automatically mapped to the paths suitable in hosts where dockerd runs.- How I did it
I introduced a new
"bindMaps
" member in.docker/config.json
.It defines paths to map.
For example, if your local path
/home/ikedam
is actually located on/exports/ikedam
on the host where dockerd run, your.docker/config.json
would be like this:That configuration converts
docker run -v "/home/ikedam/work:/worksapce" ...
todocker run -v "/exports/ikedam/work:/workspace", and that would work correct on the remote machine. It would be especially useful when used with
docker run -v "./work:/workspace" ...or
docker run -v "$(pwd)/work:/workspace" ...`.- How to verify it
Instructions to test on Windows and WSL2:
Build
docker
command:checkout this branch.
Build a command for Windows (This must be performed on an environment with docker):
build\docker-windows-amd64.exe
will be available and rename that todocker.exe
.Set up WSL2 distribution (You can skip here if you have already an appropriate WSL2 distribution available):
Set the version of WSL to 2.
Install Ubuntu-20.04.
Set up your unix user.
Install dockerd on WSL2:
Install Docker Engine following the instructions in https://docs.docker.com/engine/install/ubuntu/
Configure dockerd to accept 127.0.0.1:2375 (for access from Windows)
Start dockerd. NOTE: dockerd doesn't start automatically, and you must start it every time you log onto Windows.
Test bindMaps feature from Windows:
Create %USERPROFILE%.docker\config.json like this:
Configure DOCKER_HOST to connect to dockerd on WSL2:
Run
docker
command. Consider builtdocker
command is available in the current directory:Invoke-WebResuest
would contain "test!". That means bindMaps feature allows you to specify bind mount with Windows paths, even though the docker daemon run on a WSL2 distribution.- Description for the changelog
Add bindMaps feature: host paths in bind mounts can be mapped to another paths, like actual paths on the remote machine
closes #3786