Juan Jimenez
Juan Jimenez

Reputation: 501

Setting umask for container running as jenkins

Because of restrictions on some of the tools we use, our Docker containers do not run as root. In the Dockerfile, the last thing I do is switch to the jenkins user. However, I need to set the umask to 0002. Putting a "RUN umask 0002" after "USER jenkins" doesn't work. How do I do this?

Upvotes: 0

Views: 188

Answers (1)

datawookie
datawookie

Reputation: 6534

You can set the umask for interactive shells by adding it to .bashrc.

FROM ubuntu:22.04

RUN useradd -m jenkins && \
    echo "umask 0002" >>/home/jenkins/.bashrc

USER jenkins
WORKDIR /home/jenkins

This will not be applied to subsequent RUN or CMD statements but it will work in an interactive shell.

enter image description here

Upvotes: 0

Related Questions