简体   繁体   English

docker-compose 错误:Windows 上的“没有这样的文件或目录”

[英]docker-compose error: "no such file or directory" on Windows

I am following along with this tutorial for running a Flask server using Docker.我正在跟随本教程使用 Docker 运行 Flask 服务器。 I am working on a Windows machine so I am using Docker Toolbox.我在 Windows 机器上工作,所以我使用 Docker 工具箱。

Once I enter the command to create the database table:一旦我输入命令来创建数据库表:

docker-compose run web /usr/local/bin/python create_db.py 

I get the following error:我收到以下错误:

Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \\"C:/Program Files/Git/usr/local/bin/python\\": stat C:/Program Files/Git/usr/local/bin/python: no such file or directory": unknown来自守护进程的错误响应:OCI 运行时创建失败:container_linux.go:346:启动容器进程导致“exec:\\”C:/Program Files/Git/usr/local/bin/python\\”:stat C:/Program Files/ Git/usr/local/bin/python:没有这样的文件或目录”:未知

I am not sure why I am getting this error, any suggestions on how to fix this error would be greatly appreciated.我不确定为什么我会收到这个错误,关于如何解决这个错误的任何建议将不胜感激。 Thank you.谢谢你。

The command fails because windows tries to parse the path, this can be circumvented by quoting the path:该命令失败,因为 Windows 尝试解析路径,这可以通过引用路径来规避:

docker-compose run web python create_db.py

If the above fails a double dash can be used:如果以上失败,可以使用双破折号:

docker-compose run web -- "/usr/local/bin/python create_db.py"

我不得不更改当前目录,然后执行脚本:

docker-compose run web bash -c "cd /usr/local/bin/; python create_db.py"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM