21

I want to build a jenkins docker container with root permissions so that i can us apt-get feature to install gradle.

I am using this command to run jenkins on 8080 port but i also want to add gradle as enviornment variable :

docker run -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home jenkins

or what dockerfile i need to create and what to write in it so that jenkins also start running at 8080

Sidharth
  • 1,402
  • 2
  • 16
  • 37
  • i was trying a wrong command which just created a directory with name gradle in container running jenkins. but then i able to enter as root and installed gradle. i will post answer to my question now. Thanks anyway :) @StephenKing – Sidharth Nov 10 '16 at 04:52

3 Answers3

60

I am now able to login into my docker container as root and apt-get can be used to install gradle or anything manually into the container.

Command i used to enter as root in container :

docker exec -u 0 -it mycontainer bash
Sidharth
  • 1,402
  • 2
  • 16
  • 37
0

Building an image that sets USER to root will make all interactive logins use root.

Dockerfile

FROM jenkins/jenkins

USER root

Then (setting your container ID):

docker exec -it jenkins_jenkins_1 bash
root@9e8f16419754:/$
Steven Spungin
  • 27,002
  • 5
  • 88
  • 78
  • Building an image that sets USER to root will make all interactive logins use root Is this risk to make default user in Jenkins image root? – java dev Dec 31 '21 at 22:16
0

docker run --user=root -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home jenkins

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 05 '23 at 05:46