Python Docker Compose Up 给出“系统找不到指定的文件”。错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42052270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Docker Compose Up gives "The system cannot find the file specified." error
提问by Yahya Uddin
I have recently installed Docker Toolbox on my Windows 10 machine.
我最近在我的 Windows 10 机器上安装了 Docker Toolbox。
However, whenever I run docker-compose up
I get the following error message:
但是,每当我运行时,都会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
Note that I have C:\Python27
and C:\Python27\Scripts
in both my userand systemenvironment variables. I also tried this using Python 3, and it still doesn't work.
请注意,我C:\Python27
并C:\Python27\Scripts
在我的两个用户和系统环境变量。我也使用 Python 3 尝试过这个,但它仍然不起作用。
采纳答案by jenming
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.
你和我可能有也可能没有同样的问题。在上面@Haken Lid 发布的链接中,问题在于 PATH 环境变量没有正确版本的 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>
.
在我运行docker-compose <any command>
.
回答by Razze
I just forgot to start "Docker for Windows" which resulted in that error.
我只是忘记启动导致该错误的“Docker for Windows”。
回答by Abdourahmane FALL
Run docker-compose
with the Docker Quickstart Terminal. It will solve your error.
docker-compose
使用 Docker 快速入门终端运行。它将解决您的错误。
The Docker Quickstart Terminalis 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>)
eval $(docker-machine env <MACHINE_NAME>)
回答by Mike Glenn
Make sure Docker for Windows is up and running in the system tray. That was my problem.
确保 Docker for Windows 已启动并在系统托盘中运行。那是我的问题。
回答by Bala
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
回答by Dustin Rasener
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.
我在 Windows 10 上全新安装 Docker 时遇到了这个问题。我的问题是我实际上没有先运行 Docker;我刚刚安装了 .msi 并从命令行运行了“docker-compose”。
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.
一旦我运行了 Docker(并遵循了更多的安装后步骤,包括注销并重新启动我的计算机),我就可以docker-compose
毫无问题地运行了。
回答by Maria Ines Parnisari
I spent close to an hour fixing this issue on my Windows machine.
我花了将近一个小时在我的 Windows 机器上解决这个问题。
- Install Python(version 3.6.1 worked fine for me), selecting the option "add to PATH".
- Install Docker.
- Reboot your machine.
- On your notification bar you'll see an icon for Docker. Right-click it and select
Settings...
. Go toShared Drives
and selectC:
drive. You will be prompted for credentials. [*] - Run
docker build .
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 rundocker-compose up
.
- 安装Python(版本 3.6.1 对我来说很好用),选择“添加到 PATH”选项。
- 安装Docker。
- 重新启动您的机器。
- 在您的通知栏上,您会看到一个 Docker 图标。右键单击它并选择
Settings...
。转到Shared Drives
并选择C:
驱动器。系统将提示您输入凭据。[*] - 跑
docker build .
运行
docker-compose up
。[*]:如果您不执行此步骤,则在执行步骤 6 时可能会看到此错误:
ERROR: for website Cannot create container for service website: C: drive is not shared. Please share it in Docker for Windows Settings
。如果在输入您的凭据后未选中 C: 驱动器,请为您的计算机创建一个新用户,该用户对您将运行的文件夹具有完全访问权限docker-compose up
。
回答by AUBG
Quitting Docker and stopping Docker VM solved this for me.
退出 Docker 并停止 Docker VM 为我解决了这个问题。
回答by HackAfro
In Docker Quickstart Terminal I ran docker-machine env
, and it gave me:
在 Docker Quickstart Terminal 我跑了docker-machine env
,它给了我:
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!
我跑了eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)
。就是这样!
This solution was copied from this issue. I'm on a Windows 10 Home. This solved my problem.
这个解决方案是从这个问题复制的。我在 Windows 10 家庭版上。这解决了我的问题。
回答by Ashwin J Chhetri
I have used Docker Toolbox since I am on Windows 8.1. After many hours of troubleshooting I solved this issue by:
我在 Windows 8.1 上使用过 Docker Toolbox。经过数小时的故障排除后,我通过以下方式解决了这个问题:
- 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.
- 卸载 Python 2.7 并安装 Python 3.6.4 并将其添加到环境变量中。
- 重新启动 Docker 快速入门终端并从那里运行命令。