Docker Compose Up gives “The system cannot find the file specified.” error

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

However, whenever I run docker-compose up I get the following error message:

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 

Note that I have C:\Python27 and C:\Python27\Scripts in both my user and system environment variables. I also tried this using Python 3, and it still doesn't work.

回答1:

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>.



回答2:

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



回答3:

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>)



回答4:

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



回答5:

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 


回答6:

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.



回答7:

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.



回答8:

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



回答9:

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.



回答10:

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.


回答11:

Quitting Docker and stopping Docker VM solved this for me.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!