rails/docked

No write access after creating new app

SalvesTestservices opened this issue · 4 comments

After creating a new rails application with Docked, all files and folders are read-only.
And when I create a new file, e.g. a controller, it gives me permission denied.
So it seems the write permissions are not set correct?
When I create a Rails app without Docked in the same directory, I don't have this issue.
It is on Ubuntu 22.04 on Windows WSL2.

This happens because the docker daemon runs with privileges by default.
Either run sudo chown -R <your user> * after a command that generates files or install Docker as a non root user (make sure to understand the limitations that comes with it) https://docs.docker.com/engine/security/rootless/

Yes, I did a chmod on the files and that helped, but maybe add a note to the readme?
I can understand this is confusing for users, who are not that familiar with Linux.

gior commented

Alternatively, add -u $(id -u):$(id -g) to the docked alias to use current user id and group:

alias docked='docker run --rm -it -v ${PWD}:/rails -v ruby-bundle-cache:/bundle -u $(id -u):$(id -g) -p 3000:3000 ghcr.io/rails/cli'

Files created by the container will be owned by the current user instead of root. It doesn't require the container's OS to define a user similar the one running the command on the host.