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
User creation fails: Add parameters for user and group id in dockerfile. #3692
base: master
Are you sure you want to change the base?
Conversation
Add a user and group id environment variable. These can be used by the entrypoint script to create the user correctly. Without any parameter it will the root id's (0:0) because the directory opt/zotonic is created by the root user.
Dockerfile.dev
Outdated
@@ -1,5 +1,8 @@ | |||
FROM erlang:24-alpine | |||
|
|||
ENV PUID=1000 | |||
ENV PGID=1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why default to 1000? Shouldn't this be derived from the current user?
The stat
construct is to fix access permission errors on the directories and files accessed by the container, when accessing and updating files owned by the user running the container. For this we want to use the same UID and GID in the container as the current user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we need something similar to this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is as following:
- The directory opt/zotonic is not present on a clean install, so it is created by the default user the base image is using; the root user.
- The docker/docker-entrypoint.sh script then performs a
stat
on the opt/zotonic directory, and get 0:0, the root user's UID and GID. - It then tries to create the user zotonic with UID and GID 0, which fails of course.
To reproduce: delete the zotonic volume, and run ./start-docker.sh
.
To see the issue in de container itself: docker run --rm -it --entrypoint /bin/bash zotonic/zotonic-dev
then ls -al /opt/zotonic
, notice the directory is owned the root user.
Fixing it in the docker-compose file works too, but then you will still not be able to build the image using something like docker build -f Dockerfile.dev -t zotonic/zotonic-dev:latest .
.
The entrypoint script of the container is creating the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering why the directory opt/zotonic
is not present on clean install.
Isn't it mounted before the install script?
Add a user and group id environment variable. These can be used by the entrypoint script to create the user correctly. Without any parameter it will the root id's (0:0) because the directory opt/zotonic is created by the root user.