This post was most recently updated on March 3rd, 2023.
3 min read.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
- Admin rights are not required for Docker on Windows anymore. It still seems to occasionally break, though. This Q on SO has some details on it: https://stackoverflow.com/questions/58663920/can-i-run-docker-desktop-on-windows-without-admin-privileges#:~:text=If%20your%20admin%20account%20is,the%20changes%20to%20take%20effect.
- “Performing cleanup” – Excel is stuck with an old, conflicted file and will never recover. - November 12, 2024
- How to add multiple app URIs for your Entra app registration? - November 5, 2024
- How to access Environment Secrets with GitHub Actions? - October 29, 2024