-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rootless container permission error #1287
Comments
By
That's what |
Yes, the user is shown as 1000 inside the container but automatically translated to a subuid in the host (using podman) so i can't just set user: $subuid:$subgid
From what i know user: is set before the dockerfile is executed, so if you're using root user in dockerfile to setup stuff it won't work, ideally we would change with USER at the end of the dockerfile just before the entrypoint execution. FROM ...
ARG UID=1000
ARG GID=1000
RUN useradd -m -u $UID -g $GID -o postgres
# do stuff
# add folder perms/owns to postgres user
USER postgres
ENTRYPOINT [“...”] The bitnami postgres image does something like this. The current case is worse than that as the permission stuff is handled in the entrypoint, thus inside the container not while creating the image, which btw security-wise isn't really exciting |
I think you're misunderstanding something -- setting You might be able to get the correct permissions on your directory by doing something like |
I understand, what i'm suggesting is running stuff (as root) in the dockerfile before using USER with predefined/env gid & uid instead of relying on user:/--user as the latter's value can't be used in the dockerfile since its value is unknown at that stage This way:
|
I think you're still missing something -- we don't create any database in the I don't have rootless podman handy (nor anywhere I can really set it up ATM), but I do have rootless Docker which is the same for the most part (all the same underlying kernel functions), on which I can demonstrate: $ id
uid=1000(rootless) gid=1000(rootless) groups=1000(rootless)
$ grep rootless /etc/subuid
rootless:100000:65536
$ pidof dockerd
106
$ ps | grep 106
106 rootless 0:05 dockerd --host=unix:///run/user/1000/docker.sock --host=tcp://0.0.0.0:2376 --tlsverify --tlscacert /certs/server/ca.pem --tlscert /certs/server/cert.pem --tlskey /certs/server/key.pem
$ docker run -dit --name psql --user postgres:postgres --pull=always --env POSTGRES_PASSWORD=postgres postgres
latest: Pulling from library/postgres
Digest: sha256:8d3be35b184e70d81e54cbcbd3df3c0b47f37d06482c0dd1c140db5dbcc6a808
Status: Downloaded newer image for postgres:latest
b601a5a030b0815931d64c5326676ba4dd12362b1c78c40d4b9df4db67701a53
$ docker logs psql | tail -n1
2024-11-05 00:10:49.056 UTC [1] LOG: database system is ready to accept connections
$ docker container inspect psql --format '{{ .State.Pid }}'
574
$ ps | grep 574
574 100998 0:00 postgres
$ docker container inspect psql --format '{{ index .Mounts 0 "Source" }}'
/home/rootless/.local/share/docker/volumes/9ae7fd4bc14bd1a15cf173d35fb86982c756caa6ab57db35b48efb7dd9f6543f/_data
$ ls -lnd /home/rootless/.local/share/docker/volumes/9ae7fd4bc14bd1a15cf173d35fb86982c756caa6ab57db35b48efb7dd9f6543f/_data
drwx------ 19 100998 100998 4096 Nov 5 00:10 /home/rootless/.local/share/docker/volumes/9ae7fd4bc14bd1a15cf173d35fb86982c756caa6ab57db35b48efb7dd9f6543f/_data (Because of |
Creating a container with "user:1000:1000" in the compose file generates these errors:
This seems to happen because i'm using a subuid (which the volume correctly chowns to the bind path)
A solution to this could be to let us set the postgres user UID and GID manually, as suggested in #1068
This works without using subuids, but doesn't if so:
This doesn't work in either case:
The text was updated successfully, but these errors were encountered: