-
Notifications
You must be signed in to change notification settings - Fork 479
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
docker: Updated user and data dir handling. #5276
Conversation
Set UID and GID to 999 consistently. Start as root user for init then drop to algorand 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.
I get it and it seems alright, but I haven't tested it.
As mentioned in the Slack thread, I think a better approach than doing
As https://hub.docker.com/_/postgres/ notes, supporting arbitrary UIDs requires setting the |
What makes this a better approach? I was following the pattern used by redis and postgres. Those are both "curated containers", so it seemed like a safe pattern to follow. Also, it worked on my machine -- setting a UID/GID and mounting the passwd file did not. https://github.com/docker-library/redis/blob/fb3e83ea2c60ba55da46a5eaf114c4d77cd0e97d/7.2-rc/docker-entrypoint.sh#L11 I think there are other permission errors related to a custom UID/GID, at this time I have not looked into those problems. |
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.
Since we're not requiring the container to be run as root (the |
This is really fascinating. Thanks for the information. I attempted to explain/clarify this process as an option in the README. |
@@ -80,7 +80,7 @@ The data directory located at `/algod/data`. Mounting a volume at that location | |||
|
|||
### Volume Permissions | |||
|
|||
The container executes in the context of the `algorand` user with UID=999 and GID=999 which is handled differently depending on your operating system. During startup the container is temporarily run as `root`, after modifying the permissions of `/algod/data` it drops to the `algorand` user. This can sometimes cause problems. | |||
The container executes in the context of the `algorand` user with UID=999 and GID=999 which is handled differently depending on your operating system or deployment platform. During startup the container temporarily runs as `root` in order to modify the permissions of `/algod/data`. It then changes to the `algorand` user. This can sometimes cause problems, for example if your deployment platform doesn't allow containers to run as the root 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.
As the run.sh
only does the chown
if running as root, it seems safe to run the container in a non-root context (provided externally mounted /algorand/data has the proper write permissions already). I think this section of the README could state that as such. In any case, this reads as discouraging running as non-root, which I don't think is warranted.
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.
Help! Could you suggest an alternative phrasing? I must have reworded this 5 times before getting to this point.
From my point of view, this is how I would recommend people run their container. It seems less likely to get us bug reports compared to telling people how to configure the data directory and UID. I tried to make it clear that the root
user is being used so that anyone sensitive to this would not be surprised (and may even continue reading to see how to override the UID/GID.
Summary
Set UID and GID to 999 consistently.
Start as root user for init then drop to algorand user.
Test Plan
Build the container locally
Without these changes, mounting a directory fails with a permission denied error.
Also had some help from Patrick testing in kubernetes.