Error response from daemon: Unrecognised volume spec: file '\\.\pipe\docker_engine' cannot be mapped

Error response from daemon: Unrecognised volume spec: file '\\.\pipe\docker_engine' cannot be mapped. Only directories can be mapped on this platform

The docker compose file looks like below:

version: "2.4"
services:
  traefik:
    isolation: ${TRAEFIK_ISOLATION}
    image: ${TRAEFIK_IMAGE}
    command:
      - "--ping"
      - "--api.insecure=true"
      - "--providers.docker.endpoint=npipe:////./pipe/docker_engine"
      - "--providers.docker.exposedByDefault=false"
      - "--providers.file.directory=C:/etc/traefik/config/dynamic"
      - "--entryPoints.websecure.address=:8443"
    ports:
      - "8443:443"
      - "8079:8080"
    healthcheck:
      test: ["CMD", "traefik", "healthcheck", "--ping"]
    volumes:
      - source: \\.\pipe\docker_engine
        target: \\.\pipe\docker_engine
        type: npipe
      - ./traefik:C:/etc/traefik
    depends_on:
....
 

在确认docker已经正常启动了,而且使用的也是Windows containers的情况下,可以尝试在named pipe后面加上”\"。如下:

   - source: \\.\pipe\docker_engine\
        target: \\.\pipe\docker_engine\
        type: npipe
 
以上方法在Docker on Windows 3.4.0 + Windows 10 Pro 20H2上测试通过。