Humair Ali
Humair Ali

Reputation: 71

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:

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:

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.

Upvotes: 3

Views: 6514

Answers (2)

jafojial
jafojial

Reputation: 131

Verify that Docker is started and try again

Upvotes: 6

verdier
verdier

Reputation: 64

It seems the error you're facing is due to the path specified in the volumes on your 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.

Remember that on Windows / is equal to \. 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.

Upvotes: 0

Related Questions