Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ptrck0
Copy link
Contributor

@ptrck0 ptrck0 commented Feb 26, 2024

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.

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
Copy link
Member

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.

Copy link
Member

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:

https://stackoverflow.com/a/71027261

Copy link
Contributor Author

@ptrck0 ptrck0 Mar 1, 2024

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.

Copy link
Member

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?

@mworrell
Copy link
Member

@ptrck0 I have an alternative setup here, using your method of building the docker image in-situ. #3723

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

Successfully merging this pull request may close these issues.

None yet

2 participants