簡體   English   中英

無法在 Windows 10 中執行腳本 docker-compose YML 文件

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

我正在使用 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

完整摘錄如下:

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 撰寫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"

我不確定是什么原因導致這個問題,因為我是 docker 的新手。請提供您的建議,謝謝。

驗證 Docker 是否已啟動,然后重試

您面臨的錯誤似乎是由於您的 docker-composer 上的卷中指定的路徑:

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

您基本上是在告訴 docker 安裝一個不存在的卷,因為您在 Windows 10 上使用 Linux 路徑結構。

請記住,在 Windows /上等於\ 否則,最好嘗試使用絕對路徑,以便更好地發現問題。

您可以在此鏈接上找到有關 windows 路徑的更多信息,在此其他鏈接中,您可以在 docker-composer 中找到有關卷的更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM