8

I have Docker installed on my Windows OS. There is my volumes filed of docker-compose.yml:

volumes:
  - "/var/run/docker.sock:/var/run/docker.sock"

I just can't figure out how /var/run/docker.sock::/var/run/docker.sock path works for windows as I have no /var/run/ on my windows files where I can find docker.sock. So how this volume binding works at all?

2
  • Is this for a Linux image on Windows or native Windows image? docker system info --format '{{.OSType}}'
    – BMitch
    Commented May 9, 2019 at 18:33
  • Linux image on Windows Commented May 9, 2019 at 18:44

2 Answers 2

7

The /var/run/docker.sock file on Docker for Mac and Windows for Linux images is inside the VM that Docker uses to run Linux containers. Those volume mounts happen from inside of that VM to the containers running in the VM. This is also why you can get an empty directory if you try to run a volume mount to a directory that you have not shared with the embedded VM.

You cannot see this file directly from the Windows environment (at least not that I'm aware of), though you can mount it into a container and see it that way.

For more details on how this VM is created, you can see the LinuxKit project: https://github.com/linuxkit/linuxkit

0

On mac/linux, /var/run/docker.sock is a unix sock which is used between process communication.

But windows doesn't has the unix sock, so it use named pipe instead.

When windows docker runs, you can use docker context inspect to see the npipe:////./pipe/docker_engine.

docker context inspect
[
    {
        "Name": "default",
        "Metadata": {},
        "Endpoints": {
            "docker": {
                "Host": "npipe:////./pipe/docker_engine",
                "SkipTLSVerify": false
            }
        },
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "\u003cIN MEMORY\u003e",
            "TLSPath": "\u003cIN MEMORY\u003e"
        }
    }
]

And on windows if you want to bind /var/run/docker.sock, you can use it like this: which is often used by some CI/CD jobs

    volumes:
      - //var/run/docker.sock:/var/run/docker.sock

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.