[英]Docker isn't mounting the directory? "OCI runtime create failed: container_linux.go:346: no such file or directory: unknown"
On my Windows 10 Home computer with Docker Toolbox, Docker is having trouble mounting the drives.在我的带有 Docker 工具箱的 Windows 10 家用计算机上,Docker 在安装驱动器时遇到问题。 I've already run dos2unix on the entrypoint.sh file.
我已经在 entrypoint.sh 文件上运行了 dos2unix。
The full error is as such:完整的错误是这样的:
ERROR: for users Cannot start service users: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"/usr/src/app/entrypoint.sh\": stat /usr/src/app/entrypoint.sh: no such file or directory": unknown
My docker-compose.yml:我的 docker-compose.yml:
version: '3.7'
services:
users:
build:
context: ./services/users
dockerfile: Dockerfile
entrypoint: ['/usr/src/app/entrypoint.sh']
volumes:
- './services/users:/usr/src/app'
ports:
- 5001:5000
environment:
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgresql://postgres:postgres@users-db:5432/users_dev
- DATABASE_TEST_URL=postgresql://postgres:postgres@users-db:5432/users_test
depends_on:
- users-db
Curiously, when I comment out the "volumes" section, it works.奇怪的是,当我注释掉“卷”部分时,它起作用了。 But I want to be able to mount volumes in the future.
但我希望将来能够挂载卷。
Directory structure can be seen as such:目录结构可以这样看:
D:\flask-react-auth
│ .gitignore
│ .gitlab-ci.yml
│ docker-compose.yml
│ README.md
│ release.sh
│
└───services
│
└───users
│ .coveragerc
│ .dockerignore
│ Dockerfile
│ Dockerfile.prod
│ entrypoint.sh
│ manage.py
│ requirements-dev.txt
│ requirements.txt
│ setup.cfg
│ tree.txt
│
└───project
│ config.py
│ __init__.py
│
├───api
│ │ ping.py
│ │ __init__.py
│ │
│ └───users
│ admin.py
│ crud.py
│ models.py
│ views.py
│ __init__.py
│
├───db
│ create.sql
│ Dockerfile
│
└───tests
conftest.py
pytest.ini
test_admin.py
test_config.py
test_ping.py
test_users.py
test_users_unit.py
__init__.py
I have added the D:\flask-react-auth\
to the 'Shared Folders' on virtualbox as well.我也将
D:\flask-react-auth\
添加到 virtualbox 上的“共享文件夹”。
The answer seems obvious to me:答案对我来说似乎很明显:
When you run the code as is * it mounts the current working directory to '/usr/src/app'.当您按原样运行代码时 * 它会将当前工作目录挂载到“/usr/src/app”。 * The current working directory does not have a file 'entrypoint.sh'.
* 当前工作目录没有文件“entrypoint.sh”。 * It tries to run '/usr/src/app/entrypoint.sh' but it is not there so it fails.
* 它试图运行 '/usr/src/app/entrypoint.sh' 但它不在那里,所以它失败了。
When you comment out that volume mount * I assume the image already has '/usr/src/app/entrypoint.sh' so it just works.当您注释掉那个 volume mount * 我假设图像已经有 '/usr/src/app/entrypoint.sh' 所以它可以正常工作。
I think you probably should change the mounting code from我认为您可能应该更改安装代码
volumes:
- '.:/usr/src/app'
to到
volumes:
- './services/users:/usr/src/app'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.