【问题标题】:Cannot start service web: OCI runtime create failed:无法启动服务 web:OCI 运行时创建失败:
【发布时间】:2019-12-31 14:47:49
【问题描述】:

当我执行命令docker-compose up -d时可以请教一些帮助

我得到错误你能帮我如何使用 nginx 执行 php

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;
             }
     }

【问题讨论】:

    标签: php docker docker-compose docker-for-windows nginx-config


    【解决方案1】:

    将此- ./default.conf:/etc/nginx/conf.d/ 更改为:

    - ./default.conf:/etc/nginx/conf.d/default.conf
    

    您可以在错误中看到Docker 试图将文件default.conf 挂载到文件夹conf.d

    【讨论】:

    • 这行得通,但是为什么我不能在浏览器中执行 php app.dev,它说无法连接..我的配置中缺少什么?
    • 也将第一个网络卷添加到php?
    猜你喜欢
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 2022-12-03
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 2017-02-03
    相关资源
    最近更新 更多