Docker Compose入门指南 [英] Docker Compose Getting Started guide
问题描述
我正在遵循Docker Compose入门指南( https://docs.docker.com/撰写/ gettingstarted / ),而我完全遵循了该指南。我的 Dockerfile
, docker-compose.yml
以及目录中的所有其他文件与指南中显示的完全相同
I'm following the Docker Compose getting started guide (https://docs.docker.com/compose/gettingstarted/) and I've followed the guide exactly. My Dockerfile
, docker-compose.yml
, and all other files in the directory are exactly as they appear in the guide.
但是,当我尝试运行 docker-compose up
时,Web服务会立即退出并显示退出代码2,并显示错误消息:
However, when I attempt to run docker-compose up
, the web service exits immediately with an exit code of 2, and an error message:
web_1 | python: can't open file 'app.py': [Errno 2] No such file or directory
如果自行运行,即
docker build -t composetestweb .
docker run -d -p 5000:5000 composetestweb
该网站吐出了一个错误,
The website spits out an error, but it does respond.
检查组成的容器似乎显示正确的信息:命令,装入的文件夹和工作目录都正确。
Inspecting the composed container appears to present the correct information: the command, mounted folders, and working directory are all correct.
我正在Windows 7和VirtualBox 4.3.38上使用Docker Machine。记录下来,到目前为止,我对任何其他Docker指南都没有任何疑问。
I'm using Docker Machine on Windows 7 with VirtualBox 4.3.38. For the record, I haven't had any problems with any other Docker guides up to this point.
推荐答案
最常见的原因错误的原因是使用 docker-machine
和 $ HOME
目录的项目输出。 docker-machine
只会为主目录创建Virtualbox共享文件夹,因此,如果您的项目不在该目录下,则的卷为:$ c在
docker-compose
中使用的$ c>不起作用。
The most common cause of this error is using docker-machine
and a project output of your $HOME
directory. docker-machine
will only create a Virtualbox shared folder for the home directory, so if your project is outside of that directory the volumes:
used in the docker-compose
will not work.
您有以下选择:
- 将项目移动到主目录下的目录
- 将另一个共享文件夹添加到virtualbox中,其中您存储项目
- 不要使用
卷:
,将其从docker-compose 中删除
code>
- move the project to a directory under your home directory
- add another shared folder to virtualbox for the folder where you store your projects
- don't use
volumes:
, removing it from thedocker-compose
这篇关于Docker Compose入门指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!