docker / docker/docker-py

Cannot mount binds with windows source

Open
#2,661 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

I can't seem to mount paths originating from a Windows directory using the docker-py.
Mounting paths using docker-compose.yml

docker_client = docker.from_env()
docker_client.containers.run(
  image='ubuntu',
  command='sleep infinity',
  remove=True,
  detach=True,
  mounts=mounts
)

I always seem to get an error:

mounts = [
  Mount(target='/app/data', source=f'/c/', type='volume')
]

400 Client Error: Bad Request ("invalid mount config for type "bind": bind source path does not exist: /c/")

or

mounts = [
  Mount(target='/app/data', source=f'C:/', type='volume')
]

400 Client Error: Bad Request ("invalid mount config for type "bind": invalid mount path: 'C:/' mount path must be absolute")

or

mounts = [
  Mount(target='/app/data', source=f'C:\', type='volume')
]

400 Client Error: Bad Request ("invalid mount config for type "bind": invalid mount path: 'C:/' mount path must be absolute")

same for //c/

using a docker-compose.yml file, everything works no problemo.

I'd not be surprised if there is a mistake somewhere, but I can't seem to figure it out.
Any help is much appreciated!

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 Mount objects passed to docker_client.containers.run and compare their Windows source-path handling with the working docker-compose.yml configuration. Reproduce the three source forms against the Docker Engine API, then confirm the client accepts a valid Windows bind source without producing the reported mount errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.