You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, after installing su-exec on an Alpine-based image for Docker I tried running it and received the following output: su-exec: setgroups: Operation not permitted
Below is a simple Dockerfile and test showing what I'm seeing.
Dockerfile
FROM alpine
RUN apk update
RUN apk add --no-cache bash su-exec \
&& rm -rf /var/cache/apk/*
RUN addgroup -g 82 -S www-data \
&& adduser -u 82 -D -S -G www-data www-data
USER www-data
Command
# su-exec root /bin/bash
su-exec: setgroups: Operation not permitted
OK, so I think I just answered my own question. It looks like after installing su-exec it doesn't have the proper permissions to be able to execute under a different user. It looks like running chmod u+s /sbin/su-exec during the build gets everything working.
i don't think it is a good idea to chmod u+s it as it means that any user could run as root. The purpose of this tool is to drop root permissions, not to elevate permissions. Use sudo if you need elevate permissions.
This issue should be closed since Dockerfile's USER directive is incompatible with su-exec.
This can be seen in the Best practices for building secure Docker images video. Without USER specified docker exec container_name ps will run ps as root (~6 minutes in), but when USER is specified everything starts running as this user (~8 minutes in).
Activity
swquinn commentedon Mar 29, 2016
OK, so I think I just answered my own question. It looks like after installing
su-execit doesn't have the proper permissions to be able to execute under a different user. It looks like runningchmod u+s /sbin/su-execduring the build gets everything working.Sorry for wasting your time!
ncopa commentedon Mar 29, 2016
i don't think it is a good idea to
chmod u+sit as it means that any user could run as root. The purpose of this tool is to drop root permissions, not to elevate permissions. Usesudoif you need elevate permissions.swquinn commentedon Mar 29, 2016
Ah, interesting. OK. I guess I had misunderstood its usage when I read the example that used the command:
su-exec root ...Thanks for the clarification!
hlovdal commentedon Oct 14, 2017
This issue should be closed since Dockerfile's
USERdirective is incompatible with su-exec.This can be seen in the Best practices for building secure Docker images video. Without USER specified
docker exec container_name pswill runpsas root (~6 minutes in), but when USER is specified everything starts running as this user (~8 minutes in).binarymist commentedon Oct 18, 2018
What's your solution @hlovdal to this then: moby/moby#2259
Obviously this won't work: https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
The incompatibility is also not mentioned here: https://github.com/ncopa/su-exec