Skip to content

"setgroups" operation not permitted? #2

Closed

Description

@swquinn

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

Activity

  1. swquinn commented on Mar 29, 2016

    @swquinn
    Author

    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.

    Sorry for wasting your time!

  2. ncopa commented on Mar 29, 2016

    @ncopa
    Owner

    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.

  3. swquinn commented on Mar 29, 2016

    @swquinn
    Author

    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!

  4. hlovdal commented on Oct 14, 2017

    @hlovdal
    Contributor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions