我是否需要创建自己的 nginx.conf 文件才能成功运行这个 docker-composer.yml 文件?

问题描述

我正在尝试在本地启动并运行 nextcloud + mariadb + Nginx docker-compose,但在处理 Nginx.conf 文件时我被卡住了。我正在关注this guide at the base-fpm section。这是 docker-compose.yml 文件,我在 CLI 中运行的内容以及我得到的错误

version: '2'
volumes:
  nextcloud:
  db:
services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - db:/var/lib/MysqL
    environment:
      - MysqL_ROOT_PASSWORD=mypw
      - MysqL_PASSWORD=mypw
      - MysqL_DATABASE=nextcloud
      - MysqL_USER=nextcloud
  app:
    image: nextcloud:fpm
    restart: always
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MysqL_PASSWORD=mypw
      - MysqL_DATABASE=nextcloud
      - MysqL_USER=nextcloud
      - MysqL_HOST=db
  web:
    image: Nginx
    restart: always
    ports:
      - 8080:80
    links:
      - app
    volumes:
      - ./Nginx.conf:/etc/Nginx/Nginx.conf:ro
    volumes_from:
      - app
$ docker-compose up
Creating network "nextcloud_default" with the default driver
Creating volume "nextcloud_nextcloud" with default driver
Creating volume "nextcloud_db" with default driver
Creating nextcloud_db_1 ... done
Creating nextcloud_app_1 ... done
Creating nextcloud_web_1 ... error

ERROR: for nextcloud_web_1  Cannot start service web: OCI runtime create Failed: 
container_linux.go:370: starting container process caused: process_linux.go:459: container init 
caused: rootfs_linux.go:59: mounting "/home/Nowak/docker/nextcloud/Nginx.conf" to rootfs at 
"/var/lib/docker/overlay2/4869db7f0302ec8b7e5f4328b861e64627daa78728d443913052cecd1cd095a9/merge
d/etc/Nginx/Nginx.conf" 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:370: 
starting container process caused: process_linux.go:459: container init caused: 
rootfs_linux.go:59: mounting "/home/Nowak/docker/nextcloud/Nginx.conf" to rootfs at 
"/var/lib/docker/overlay2/4869db7f0302ec8b7e5f4328b861e64627daa78728d443913052cecd1cd095a9/merge
d/etc/Nginx/Nginx.conf" 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.

我需要创建一个 Nginx.conf 文件并将其放在我的工作目录中吗? 该指南确实提到了这一点:

Nginx 的配置存储在配置文件 Nginx.conf 中,该文件被挂载到容器中。在示例部分 here 中可以找到示例。

但是当我点击那个链接时,我似乎找不到任何 Nginx.conf 文件的例子。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)