nginx – Getting a container startup error when attempting to run Nextcloud in Docker

I am wanting to run Nextcloud is a Docker container on a Debian server. Currently this is my Docker compose file:

services:
  # Note: PostgreSQL is an external service. You can find more information about the configuration here:
  # https://hub.docker.com/_/postgres
  db:
    # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server
    image: postgres:alpine
    container_name: pw_cloud_db
    restart: always
    volumes:
      - db:/var/lib/postgresql/data:Z
    env_file:
      - db.env

  # Note: Redis is an external service. You can find more information about the configuration here:
  # https://hub.docker.com/_/redis
  redis:
    image: redis:alpine
    container_name: pw_cloud_redis
    restart: always

  app:
    image: nextcloud:fpm-alpine
    container_name: pw_cloud_main
    restart: always
    volumes:
      - /media/cloud_drive/pw_cloud:/var/www/html
      # NOTE: The `volumes` config of the `cron` and `app` containers must match
    environment:
      - POSTGRES_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis

  # Note: Nginx is an external service. You can find more information about the configuration here:
  # https://hub.docker.com/_/nginx/
  web:
    image: nginx:alpine-slim
    container_name: pw_cloud_nginx
    restart: always
    ports:
      - 127.0.0.1:8080:80
    volumes:
      # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html
      - ./web/nginx.conf:/etc/nginx/nginx.conf:ro  
      # NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing)
      - /media/cloud_drive/pw_cloud:/var/www/html
    depends_on:
      - app

  cron:
    image: nextcloud:fpm-alpine
    container_name: pw_cloud_cron
    restart: always
    volumes:
      - /media/cloud_drive/pw_cloud:/var/www/html
      # NOTE: The `volumes` config of the `cron` and `app` containers must match
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

volumes:
  db:
  nextcloud:

Yet this results in the following error message:

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/containers/pw_cloud/web/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": create mountpoint for /etc/nginx/nginx.conf mount: cannot create subdirectories in "/var/lib/docker/overlay2/f999a4c7acb943347d0f1ef1488bffd6c723b3e0a7afe67ed58ac41e77386956/merged/etc/nginx/nginx.conf": 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

I am running this in /var/containers if that makes any difference.

I setting the nginx web folder for 755 but that doesn’t fix the issue neither, not sure what is the cause or fix. Looking online it seems like this was a bug back in 2016 but that was long since fixed based on the pull request.

Read more here: Source link