I want to change an alpine-based container user’s UID and GID.
But there’s no usermod
and groupmod
. Are there equivalents?
(This is for a running container, not an image.)
I want to change an alpine-based container user’s UID and GID.
But there’s no usermod
and groupmod
. Are there equivalents?
(This is for a running container, not an image.)
2
Answers
This is my workaround (must be put in an entrypoint script):
Please let me know if there's a way to do this without installing anything.
Assuming the group and user exist before the container is created you can simply run the container with the proper user:group uid:gid.
The
docker run
command can be passed a user and group (or uid / gid).docker run --user 2000:2000 acme
Or, via compose, the
user:
attribute can be used.compose.yml