title: How to mount a Windows path volume inside a Docker container
body: <p>It's OK when I use <code>docker run --rm -v C:\Python39:/mnt --entrypoint ls alpine -la /mnt</code> to mount a Windows path into a container in <strong>a native Windows shell</strong>. But when I mount Windows <code>//var/run/docker.sock</code> into a container and try to run previous command inside this container it will throw an error.</p>
  <pre><code>docker.errors.APIError: 500 Server Error: Internal Server Error (&quot;invalid volume specification: 'C:\Python39:/mnt:ro'&quot;)
  </code></pre>
  <p>a.py</p>
  <pre><code>import docker
  import os
  
  print(os.environ[&quot;COMPOSE_CONVERT_WINDOWS_PATHS&quot;])
  
  c = docker.from_env()
  
  output = c.containers.run(&quot;alpine&quot;, &quot;-la /mnt&quot;,
  entrypoint=&quot;ls&quot;, volumes={
      'C:\\Python39': {
          'bind': '/mnt',
          'mode': 'ro',
      }
  })
  print(output.decode())
  </code></pre>
  <p>Dockerfile</p>
  <pre><code>FROM python:3.9-alpine
  RUN pip install docker
  ENV COMPOSE_CONVERT_WINDOWS_PATHS=1
  ADD a.py .
  CMD [&quot;python&quot;, &quot;a.py&quot;]
  </code></pre>
  <pre><code>docker build . -t test
  docker run docker run --rm -v //var/run/docker.sock:/var/run/docker.sock test
  </code></pre>