无法启动服务 Web:OCI 运行时创建失败:

当我执行命令时,我可以问一些帮助吗?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

和 my 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

您可以在错误中看到尝试将文件装载到文件夹Dockerdefault.confconf.d


答案 2

推荐