Docker Compose Up 给出“系统无法找到指定的文件”错误

我最近在我的 Windows10机器上安装了 DockerToolbox。

但是,每当我运行 docker-compose up时,都会收到以下错误消息:

Traceback (most recent call last):
File "<string>", line 3, in <module>
File "compose\cli\main.py", line 65, in main
File "compose\cli\main.py", line 117, in perform_command
File "compose\cli\main.py", line 849, in up
File "compose\project.py", line 372, in up
File "compose\project.py", line 539, in warn_for_swarm_mode
File "site-packages\docker\api\daemon.py", line 33, in info
File "site-packages\docker\utils\decorators.py", line 47, in inner
File "site-packages\docker\client.py", line 139, in _get
File "site-packages\requests\sessions.py", line 488, in get
File "site-packages\requests\sessions.py", line 475, in request
File "site-packages\requests\sessions.py", line 596, in send
File "site-packages\requests\adapters.py", line 423, in send
File "site-packages\requests\packages\urllib3\connectionpool.py", line 595, in urlopen
File "site-packages\requests\packages\urllib3\connectionpool.py", line 363, in _make_request
File "httplib.py", line 1057, in request
File "httplib.py", line 1097, in _send_request
File "httplib.py", line 1053, in endheaders
File "httplib.py", line 897, in _send_output
File "httplib.py", line 859, in send
File "site-packages\docker\transport\npipeconn.py", line 31, in connect
File "site-packages\docker\transport\npipesocket.py", line 22, in wrapped
File "site-packages\docker\transport\npipesocket.py", line 49, in connect
pywintypes.error: (2, 'WaitNamedPipe', 'The system cannot find the file specified.')
docker-compose returned -1

注意,在我的 使用者系统环境变量中都有 C:\Python27C:\Python27\Scripts。我还用 Python3尝试了这种方法,但仍然无法工作。

88940 次浏览

You and I may or may not have the same problem. In the link posted by @Haken Lid above, the issue is with the PATH environment variable not having the correct version of Python.

BUT, for me, the issue was that I had not set all of my environment variables, by running

eval $(docker-machine env <vmname>)

before I ran the docker-compose <any command>.

You can set properties by typing the following commands:

docker-machine env --shell cmd default
@FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO @%i

Run docker-compose with the Docker Quickstart Terminal. It will solve your error.

The Docker Quickstart Terminal is mostly a regular shell but allows to create a default machine. It can be used to connect to other machines as well:

eval $(docker-machine env <MACHINE_NAME>)

I spent close to an hour fixing this issue on my Windows machine.

  1. Install Python (version 3.6.1 worked fine for me), selecting the option "add to PATH".
  2. Install Docker.
  3. Reboot your machine.
  4. On your notification bar you'll see an icon for Docker. Right-click it and select Settings.... Go to Shared Drives and select C: drive. You will be prompted for credentials. [*]
  5. Run docker build .
  6. Run docker-compose up.

    [*]: If you don't do this step you might see this error when on step 6: ERROR: for website Cannot create container for service website: C: drive is not shared. Please share it in Docker for Windows Settings. If after entering your credentials the C: drive isn't checked, create a new user for your machine that has full access to the folder where you will run docker-compose up.

I ran into this issue after the Docker Quickstart Terminal hanged a while on "Waiting for an IP..." during start up.

Restarting the Docker Quickstart Terminal fixed everything.

I had this problem with a fresh install of Docker on Windows 10. My issue was that I hadn't actually run Docker first; I just installed the .msi and ran "docker-compose" from the command line.

Once I ran Docker, (and followed a few more post-installation steps, to include logging out of and restarting my computer) I was able to run docker-compose without issue.

I just forgot to start "Docker for Windows" which resulted in that error.

Make sure Docker for Windows is up and running in the system tray. That was my problem.

I have used Docker Toolbox since I am on Windows 8.1. After many hours of troubleshooting I solved this issue by:

  • Uninstalling Python 2.7 and installing Python 3.6.4 and adding it to the environment variables.
  • Restarting Docker Quickstart Terminal and running the command from there.

In Docker Quickstart Terminal I ran docker-machine env, and it gave me:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\TheGeniesis\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"


#### Run this command to configure your shell:
eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

I ran eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env). That's it!

This solution was copied from this issue. I'm on a Windows 10 Home. This solved my problem.

Quitting Docker and stopping Docker VM solved this for me.

I had this issue today, here's what fixed it for me on Windows.

  1. I went to Docker Settings, and clicked "Reset" on the left side.
  2. I then clicked "Reset to Factory defaults..."
  3. Then went to "Shared Drives" and enabled shared drives (doesn't matter which drive) for Docker, and clicked "reset credentials", and insert my credentials.

If everything is working correctly, the box will remain checked after you click "reset credentials". If it's not, resetting your credentials will cause the box to become unchecked and you'll have to Reset Docker to Factory defaults again.

Had this issue on Windows after restarting Docker Desktop.

The solution was to close my terminal window and open a fresh one.

Same error will be caused if docker for windows was installed and activated, but never logged in..

I had the same problem.

Starting the docker daemon resolved the issue. Just search for docker pressing windows key and click on "Docker Dekstop". Daemon should be running in a minute.

You might be missing the inverted commas somewhere on the docker-compose.yml file Eg. Change volumes:

  • ./:/app:cached TO
  • "./:/app:cached"

Had same issue on Windows 10 after installing Docker using Docker Desktop Installer and left out the last installation for "WSL2 Linux kernel update package for x64 machines". After installing that and restart the laptop it was fine.

I bumped into this issue after I executed wsl --shutdown.

However, Docker Desktop still shows that it is running in the tray, but it does not show any containers which I did not delete.

Just had to make sure Docker Desktop is exited completely and relaunch it back again.

There is another chance Why this error occurring

Go to docker Dashboard settings > General

and check use Docker compose v2 is checked or not. if it is not Please it. Then try again it will work

enter image description here