#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

Docker-compose fails on Windows with "Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')"

koskila
Reading Time 4 min
Word Count 643 words
Comments 6 comments
Rating 5 (2 votes)
View

Once again, I come to you with a surprisingly opaque problem and offer to share my bemusingly simple solution. That should be a dedicated series on my blog - although on second thought, perhaps lobbing 90% of my articles under one tag wouldn't be helpful... 😁

Problem

When running docker-compose up the command would fail, and instead, output a disgustingly long set of what looks like a whole pile of pythons engaging in quantum entanglement, that would angrily hiss at you if bothered.

It's not pretty. And it turns out, it's (at least in this case) also not descriptive at all!

So the errors I got? See below:

Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')

The whole stack trace looks something like the below:

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 
   File "compose\cli\main.py", line 81, in main
   File "compose\cli\main.py", line 199, 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.')
 [6316] Failed to execute script docker-compose

Augh. The system cannot find the file specified? API version? What is going on...

Reason

The solution - at least for me - was simple. But before delving into that, let me describe my setup so that you know whether it is applicable for you or not!

I run Docker on Windows. It is configured to run on startup and just do its thing - but occasionally it suddenly needs to gulp down over 10Gb or RAM, then proceed to do nothing, and finally requires a restart.

The OS itself is fine, it seems to recover nicely. So this time, I just killed the process, waited for a few minutes, and manually ran docker-compose from PowerShell.

That's when the error was thrown at me. 😳

Solution

I was executing the command from my non-elevated PowerShell window. But that didn't match how I have configured it to run on startup - instead, I needed to run docker-compose from an elevated PowerShell console.

And to be fair, you'd do well to also make sure Docker Desktop is actually running. The service won't, at least by default, start unless the application itself is started. (This was a very valid point made by multiple people in the comments-section below - THANKS!)

I also realized my Docker Desktop won't show any of my containers when run non-elevated. I guess that's kinda obvious, right?

For you, running your stuff elevated (with admin permissions / "as an admin") or from another user profile, if that's how it's configured to run normally, might work.

Stupid? Hey, if it works... 😁

References

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
bhavya wadhwa
2022-08-21 17:49:06)
I faced the same problem, you need to open docker desktop, when it is running then try to run the command again. That works for me hope I will work for you.
Antti K. Koskela
2023-03-03 20:55:20
Ah, sometimes it's the simple stuff that ends up biting us in the behind... I'll better add a note about actually having Docker Desktop running as well, because that has actually happened to me as well. Thanks for the contribution! 👍
frank
2022-09-08 21:31:22)
I have the same problem. but run in elevated shell doesn't help. later find out the docker desktop need start first.
Antti K. Koskela
2023-03-03 20:56:04
Thanks, frank - it's a valid point. I'll mention it in the article as well!
CKolumbus
2022-10-17 19:56:38)
Just in case someone stumbles over this. I had the exact same error with docker-compose and nothing help. The i tried the newer plugin and called docker compose and it gave the following, more descriptive, error .. can you guess what was really wrong?-)
s7❯ docker compose up                                                                                          ❮ 
error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.project%3Dgitea%22%3Atrue%7D%7D&limit=0": open //./pipe/docker_engine: The system cannot find the file specified.
... Docker-desktop.. and therefore the docker daemon was not running... so it was a full fledged layer 8 problem in my case
Antti K. Koskela
2023-03-03 20:57:40
Ohh, I really like the way you've figured out a way to say "PEBKAC" in a very official-sounding yet technical way. I'm going to steal that! And also, you bring up a good point - I'll add it to the article. Thanks and have a good one!
Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-26T05:15:48Z