Help! Customize the official Jenkins Docker image failed

I followed the websit Docker
a.Create a Dockerfile with the following content:

FROM jenkins/jenkins:2.414.2-jdk17
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 docker-workflow"

b.Build a new docker image from this Dockerfile, and assign the image a meaningful name, such as “myjenkins-blueocean:2.414.2-1”:

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

I can get this logs infor:

Sending build context to Docker daemon 2.56kB

Step 1/8 : FROM jenkins/jenkins:2.414.2-jdk17

---> 5485017782fb

Step 2/8 : USER root

---> Using cache

---> 1861abe034ba

Step 3/8 : RUN apt-get update && apt-get install -y lsb-release

---> Running in b1760add3f0c

Get:1 https://packagecloud.io/github/git-lfs/debian bookworm InRelease [25.8 kB]

Get:2 https://packagecloud.io/github/git-lfs/debian bookworm/main amd64 Packages [2131 B]

Get:3 http://deb.debian.org/debian bookworm InRelease [151 kB]

Get:4 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]

Get:5 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]

Get:6 http://deb.debian.org/debian bookworm/main amd64 Packages [8906 kB]

Get:7 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [6432 B]

Get:8 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [63.2 kB]

Fetched 9255 kB in 1min 32s (101 kB/s)

Reading package lists...

E: Problem executing scripts APT::Update::Post-Invoke 'rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true'

E: Sub-process returned an error code

The command '/bin/sh -c apt-get update && apt-get install -y lsb-release' returned a non-zero code: 100

It throws error like this:
E: Problem executing scripts APT::Update::Post-Invoke ‘rm -f /var/cache/apt/archives/.deb /var/cache/apt/archives/partial/.deb /var/cache/apt/*.bin || true’

E: Sub-process returned an error code

The command ‘/bin/sh -c apt-get update && apt-get install -y lsb-release’ returned a non-zero code: 100

So, Please help me to fix it.

I can’t duplicate the problem. I tried on Debian 12 (“bookworm”) with Docker version 24.0.6, build ed223bc and on Red Hat Enterprise Linux 8 with podman acting as docker. Both were able to build the container image using the steps you listed.

I try to build dockerFile in centos7 with Docker version 20.10.8.

CentOS 7 support by the Jenkins project will end Nov 16, 2023 per the blog post. Docker 20.10.8 is a very, very old version of Docker. You’ll need to install a recent Docker release.

It’s a sad message for me.I will try to use new version Docker in centos 8.

Tks bro, @MarkEWaite

apt-get isn’t part of the CentOS distribution. You sure you’re running on this? Or am I reading this wrong?

I assumed it meant that the host operating system running docker is CentOS 7. The container definition being used is based on Debian, so the apt-get command is available.

@jonbrohauge @MarkEWaite Change the docker version,It can build the image.