Docker mount location halfway working?

EDIT: In my haste, I did not see the rules. My apologies, I have corrected this now.

  • Issue type
    Docker Compose(?), Docker Container Drive Mounting

  • OS Version/build
    Ubuntu 22 Running in VirtualBox 6.1 on Windows 10

  • App version
    20.10.17

  • Steps to reproduce
    Described below in detail, but in short:

    • Create container using docker-compose provided and run
    • Attempt to hit http://localhost:8080 or watch console for cron job status

I have scoured the internet and have tried every solution I could find to try that made sense in my situation. I am new to Docker so I am unsure I can even describe the problem I am having accurately. However, I am not new to Linux, though this is my first go around with Ubuntu. I am not running an uncommon configuration so I am truly at a loss as to what is happening and why this wont just work. I am slightly frustrated after exhausting every potential solution.

I am using Windows 10 as a Host OS, virtualizing Ubuntu 22 with VirtualBox 6.1. I have a shared folder, located at H:\Nextcloud in Windows mounted to /home/matt/Nextcloud in Ubuntu. Docker runs in the Ubuntu VM.

I am trying to make Nextcloud work in a Docker container composed with cron to run the recommended job and mysql for the backend. When I am using Nextcloud volumes, this works just fine and everything works. Things don’t work so well when I try to bind a Shared Folder location to the container.

This is the docker compose file I’m using to create the container:

version: '2'

volumes:
  db:  

services:
  db:
    image: mysql:latest
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=pwhere
      - MYSQL_PASSWORD=pwhere
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud:apache
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - type: bind
        source: /home/matt/Nextcloud
        target: /var/www/html
    environment:
      - MYSQL_PASSWORD=pwhere
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

  cron:
    image: nextcloud:apache
    restart: always
    volumes:
      - type: bind
        source: /home/matt/Nextcloud
        target: /var/www/html
    entrypoint: /cron.sh
    depends_on:
      - db

When I try to hit localhost:8080 in a browser, I get a 403 error, and watching the console shows that the cron job (which is looking for a file in /var/www/html) is also throwing an error, indicating that it cannot the file its looking for.

When I do an inspect on the nextcloud-app-1 container (the container running the NC app), I see the following

"Mounts": [
            {
                "Type": "bind",
                "Source": "/home/matt/Nextcloud",
                "Destination": "/var/www/html",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }

which suggests to me that the mount was successful. Also, when running docker exec to ls the /var/www/html path, I see the folders that exist in the share folder. So I surmise that I can see the files in docker, in Ubuntu, and in Windows. I’ve even tested creating files both in Ubuntu and in Windows and doing a ls on the Docker filesystem shows changes.

I am confused. It seems like things are working partially, but when it comes time for the docker container to serve /var/www/html or when the cron job attempts to read from that directory, docker acts like the files aren’t there, suggesting an improper mount.

I even went and used docker exec to ‘chmod -R’ the directory and I still get a 403 error in the browser, and the cron job still can’t find the specified file.

Another thing I want to add is when H:\Nextcloud does not contain Nextcloud files, they will be generated, presumably by docker compose. I can see them populate both in Windows and Ubuntu. So the Container can see the mounted drive and at least write the initial set up files to it. But beyond that, it just does not work.

As I stated, I have tried everything, scoured the internet, and spent several hours on this. I am not sure how to proceed. Any insight into this issue that can unstuck me would be appreciated a great amount and would go far in relieving this frustration I’m feeling. Thank you.

So, I was able to track down my issue and rectify my problem. I was overlooking the fact that www-data was not added to the appropriate group within my container. Once I created the group, matched the gid to the group in my VM guest, and added www-data user, it worked.

I would delete this thread if I could, but I cannot, so I thought I would at least reply to it with my answer.