Skip to content

Add user and group to all invocations of docker run #593

Open
@mahesh-panchal

Description

@mahesh-panchal

Discussion from Slack thread: https://nfcore.slack.com/archives/C043FMKUNLB/p1743470447418089

When running docker containers, either within Nextflow or on the command-line, it would be good practice to run as the user, so outputs are not written out as root user.

docker run --rm -it -u $(id -u):$(id -g) <image>

and

    docker {
        docker.enabled       = true
        docker.runOptions    = '-u $(id -u):$(id -g)'   // <- run as your user. Not root user.
    }

A drop-down box marked as a note, or a callout would also be useful the first time the user runs docker in the lesson. This would explain that docker containers are by default run as the user they were built with (often root user), and therefore the outputs written by the software are also owned by that user. In order to run as the user running the container, one needs to supply the -u option with the argument above.

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