无法启动服务 web:OCI 运行时创建失败:
Posted
技术标签:
【中文标题】无法启动服务 web:OCI 运行时创建失败:【英文标题】:Cannot start service web: OCI runtime create failed: 【发布时间】:2019-12-31 14:47:49 【问题描述】:当我执行命令docker-compose up -d
时可以请教一些帮助
Removing nginx-container
mysql-container is up-to-date
php-container is up-to-date
Recreating 2e6f7b9915c6_nginx-container ... error
ERROR: for 2e6f7b9915c6_nginx-container Cannot start service web: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/host_mnt/c/webdock/firstweb/default.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged\\\" at \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged/etc/nginx/conf.d\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/host_mnt/c/webdock/firstweb/default.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged\\\" at \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged/etc/nginx/conf.d\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
这是我的 docker-compose
version: "3.7"
services:
web:
image: nginx:latest
container_name: nginx-container
ports:
- "8080:80"
volumes:
- ./:/var/www/firstweb
- ./default.conf:/etc/nginx/conf.d/
links:
- php
php:
image: php:7-fpm
container_name: php-container
db:
image: mysql
container_name: mysql-container
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./mysql-data:/var/lib/mysql
expose:
- 3306
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: rootpass
还有我的 default.conf
server
listen 80;
index index.php;
server_name app.dev;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/firstweb;
location ~ \.php$
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
【问题讨论】:
【参考方案1】:将此- ./default.conf:/etc/nginx/conf.d/
更改为:
- ./default.conf:/etc/nginx/conf.d/default.conf
您可以在错误中看到Docker
试图将文件default.conf
挂载到文件夹conf.d
【讨论】:
这行得通,但是为什么我不能在浏览器中执行 php app.dev,它说无法连接..我的配置中缺少什么? 也将第一个网络卷添加到php
?以上是关于无法启动服务 web:OCI 运行时创建失败:的主要内容,如果未能解决你的问题,请参考以下文章
Docker:OCI 运行时创建失败:container_linux.go:349:启动容器进程导致“exec:\”java\“:$PATH 中找不到可执行文件”
无法启动服务 prometheus:oci 运行时错误:container_linux.go:235:启动容器进程导致“容器初始化过早退出”