Skip to content

Consider adding a user #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
enjunear opened this issue Dec 23, 2021 · 6 comments
Closed

Consider adding a user #278

enjunear opened this issue Dec 23, 2021 · 6 comments

Comments

@enjunear
Copy link

Per dockerfile docs, consider adding a user to the container and running as that user, instead of running as root.

@tianon
Copy link
Member

tianon commented Dec 23, 2021

Since we're FROM node, we inherit the node user it creates, which we step down to after adjusting permissions:

# allow the container to be started with `--user`
if [[ "$*" == node*current/index.js* ]] && [ "$(id -u)" = '0' ]; then
find "$GHOST_CONTENT" \! -user node -exec chown node '{}' +
exec gosu node "$BASH_SOURCE" "$@"
fi

@enjunear
Copy link
Author

enjunear commented Dec 23, 2021

Indeed.
Shouldn't the chowning be done in the Dockerfile?

@tianon
Copy link
Member

tianon commented Dec 29, 2021

The chown that's happening in the entrypoint script is happening on the user-provided volume, not on the contents of the image (we do in fact do as much chowning in the Dockerfile as we can 😅).

@tianon tianon closed this as completed Jan 3, 2022
@rabume
Copy link

rabume commented Apr 24, 2025

I would like to use the docker image for local theme development, but my host user has not the uid / gid 1000.
Container rewrites all the permissions which makes it impossible to work on my theme. Here is an example of a ghost theme with a containerized dev env: https://github.com/eddiesigner/liebling/wiki/Theme-development-with-Docker

If we could define the user from the outside this would make things a lot easier.

@yosifkit
Copy link
Member

If we could define the user from the outside this would make things a lot easier.

Use the --user flag on docker run with the user and group ids that you need. The image is designed such that any value but root should work (#54).

@rabume
Copy link

rabume commented Apr 25, 2025

Thanks for the response. I tried this flag before already but still dace the same issue. Binded host files / folder the permission gets set to the root user. Theonly thing that made it semi work was a custom docker image in wich I set the user bur then I get the issue that ghost can not read ceratin files anymore. (e.g casper theme)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants