简体   繁体   English

无法在 Windows 10 中执行脚本 docker-compose YML 文件

[英]Failed to execute script docker-compose YML file in Windows 10

I'm using windows 10 and docker toolbox and as I try docker compose up --build option, I get the following errors:我正在使用 windows 10 和 docker 工具箱,当我尝试docker compose up --build选项时,出现以下错误:

pywintypes.error: (2, 'CreateFile', 'The system cannot find the file specified.')

docker.errors.DockerException: Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.') [8628] Failed to execute script docker-compose

The full extract is as follows:完整摘录如下:

Traceback (most recent call last):
  File "docker\api\client.py", line 214, in _retrieve_server_version
  File "docker\api\daemon.py", line 181, in version
  File "docker\utils\decorators.py", line 46, in inner
  File "docker\api\client.py", line 237, in _get
  File "requests\sessions.py", line 543, in get
  File "requests\sessions.py", line 530, in request
  File "requests\sessions.py", line 643, in send
  File "requests\adapters.py", line 439, in send
  File "urllib3\connectionpool.py", line 670, in urlopen
  File "urllib3\connectionpool.py", line 392, in _make_request
  File "http\client.py", line 1255, in request
  File "http\client.py", line 1301, in _send_request
  File "http\client.py", line 1250, in endheaders
  File "http\client.py", line 1010, in _send_output
  File "http\client.py", line 950, in send
  File "docker\transport\npipeconn.py", line 32, in connect
  File "docker\transport\npipesocket.py", line 23, in wrapped
  File "docker\transport\npipesocket.py", line 72, in connect
  File "docker\transport\npipesocket.py", line 52, in connect
pywintypes.error: (2, 'CreateFile', 'The system cannot find the file specified.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 80, in main
  File "compose\cli\main.py", line 189, in perform_command
  File "compose\cli\command.py", line 60, in project_from_options
  File "compose\cli\command.py", line 152, in get_project
  File "compose\cli\docker_client.py", line 41, in get_client
  File "compose\cli\docker_client.py", line 170, in docker_client
  File "docker\api\client.py", line 197, in __init__
  File "docker\api\client.py", line 221, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')
[8628] Failed to execute script docker-compose

Docker Compose YML File is below: Docker 撰写YML文件如下:

services:
  frontend:
    build: frontend
    depends_on:
      - api
    tty: true
    volumes:
      - ./frontend/public:/frontend/public:cached,ro
      - ./frontend/src:/frontend/src:cached,ro
    ports:
      - "3000:3000"

  api:
    build: backend
    depends_on:
      - database
    tty: true
    volumes:
      - ./backend/bin:/backend/bin:cached,ro
      - ./backend/src:/backend/src:cached,ro
    ports:
      - "3001:3001"
    environment:
      DATABASE_USER: "root"
      DATABASE_PASSWORD: "1234"

  database:
    image: mongo:4.4
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: "root"
      MONGO_INITDB_ROOT_PASSWORD: "1234"

I am not sure what causes this problem, as I am new to docker. Please give your suggestions, Thanks.我不确定是什么原因导致这个问题,因为我是 docker 的新手。请提供您的建议,谢谢。

Verify that Docker is started and try again验证 Docker 是否已启动,然后重试

It seems the error you're facing is due to the path specified in the volumes on your docker-composer:您面临的错误似乎是由于您的 docker-composer 上的卷中指定的路径:

volumes:
  - ./frontend/public:/frontend/public:cached,ro
  - ./frontend/src:/frontend/src:cached,ro

You're basically telling the docker to mount a volume that doesn't exist as you're using Linux path structure on Windows 10.您基本上是在告诉 docker 安装一个不存在的卷,因为您在 Windows 10 上使用 Linux 路径结构。

Remember that on Windows / is equal to \ .请记住,在 Windows /上等于\ Otherwise, it would be best if you try to use absolute paths, to better find the issue.否则,最好尝试使用绝对路径,以便更好地发现问题。

You can find more information about windows paths on this link and in this other link you can find more information about volumes in docker-composer.您可以在此链接上找到有关 windows 路径的更多信息,在此其他链接中,您可以在 docker-composer 中找到有关卷的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM