Help with devcontainer (vs-code)

Hello!

The devcontainer seemed like a good way to avoid setting up database, apache and such as well as minimising the risk of issues stemming from my configuration possibly differing from others.

But I’m having issues getting it work…

I did:

  1. git clone (nextcloud master)
  2. made sure my local user (on the pc) is added to the docker group
  3. made sure docker is running
  4. ran vs-code from server/., and pressed “open in container”.

The devcontainer then starts, does a bunch of stuff for a long time but afterwards when its finished, localhost:80 does not work:

  • A blank page with only “Composer autoloader not found, unable to continue. Check the folder “3rdparty”. Running “git submodule update --init” will initialize the git submodule that handles the subfolder “3rdparty”.” is shown.
  • I ran git submodule update --init in the container terminal, (as doing it on the host really screws with git as it created like 12k changes from master), but now the page complains “Can’t write into config directory! This can usually be fixed by giving the webserver write access to the config directory.”

Am I doing something wrong? What is the correct procedure to start the devcontainer?

Yes, this is almost correct. You used git clone as your normal user, right? Just after you modify the server code (be it pull/merge/rebase/…), you always have to update the submodules. Just use the same user as always. This is not related to the devcontainer setup, just your local dev environment.

I just saw, the container should update the modules itself. It looks that for whatever reason, there is a permission problem with the files you created outside the dev container and inside.

Maybe you run into something like this?

I did git pull with my local user, all files belong to user:user.

It indeed seems like a permissions issue within the container, I saw now i get this error (from vscode) right after the devcontainers finish setting up:

The git repository in the current folder is potentially unsafe as the folder is owned by someone other than the current user.

In addition vs code can’t list the running containers after being opened in container mode… Which led me to the discovery that a lot of the devcontainer stuff runs as user 1001, which does not exist on my system (my user is id 1000)

It all does sound similar to the issue you link, but I’m not sure I understand how to fix it… The user inside the container is “ubuntu” which I guess maps incorrectly to 1001 instead of 1000 on host…

The postgress container seems to run with the user 999 which also seems bad…

I tried chmoding the files on host to 777, which let me start the server but it asks me to set up a user and specify database (only sqllite , so maybe postgress using user id 999 breaks the devcontainer as well?

Docker stuff is over my head, I dunno where it finds whatever user it should run as…

Unfortunately, I have little to no experience with devcontainer. I know it only from github codespaces. (I was not even aware you could use it locally).

I thing the devcontainer system tries to be intelligent but fails for whatever reason and triggers your problem. It seems not purely docker related.

If you only want to develop locally, you could get rid of the additional layer of devcontainer and directly use docker. There is a project by Julius Knorr (one of the server devs), that helps really much in setting everything up: GitHub - juliusknorr/nextcloud-docker-dev: Nextcloud development environment using docker-compose
This is how I use it locally and it works nicely. I could help you there most probably (or we could file a PR in the worst case).

Having said this, I am curious if there will be another user that might be help you directly. I hope so