I want to know the password of the root user in the Docker image

I want to know the password of the root user in the Docker image
Because I want to use it to upgrade apt and download java jdk1.8

Thats not really a thing. I would guess there’s no password.

To add new tools to the image you should extend the image - docker/README.md at master · jenkinsci/docker · GitHub

if you want to install tools at runtime, look at the tool step - Pipeline Syntax

The Jenkins tutorials extend the Docker image with additional operating system packages. They may provide good hints of the technique:

docker exec -it jenkins bash
jenkins@fe9ff04d7692:/$ su root
Password: 
su: Authentication failure
jenkins@fe9ff04d7692:/$ apt-get update && apt-get install -y ruby make more-thing-here
Reading package lists... Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
jenkins@fe9ff04d7692:/$ 

Is that so? I implemented the operation according to your manual yesterday. I used no password, but the operation failed

It is easier to build the container image with the tools that you need rather than adding the tools you need into the running container image.

Define a Dockerfile of your own, then build the container image from that Dockerfile and run the container image with the tools installed. That’s how it is done in those three pages that are linked above.

Quoting one of the pages, it says:

Create Dockerfile with the following content:

FROM jenkins/jenkins:2.361.1-jdk11
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
  https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) \
  signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
  https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins blueocean:1.25.8

Build a new docker image from this Dockerfile and assign the image a meaningful name, e.g. “myjenkins-blueocean:2.361.1-1”:

docker build -t myjenkins-blueocean:2.361.1-1 .

That example shows the container build process switching to the root user, installing a package, then switching back to the non-root user.

1 Like