Jenkins.war permission denied dockerfile

30 views Asked by At

I have the following Dockerfile:

FROM jenkins/jenkins:2.426.2
USER root

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
       make \
       git \
       curl \
       openjdk-17-jre-headless \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir /srv/backup && chown jenkins:jenkins /srv/backup

USER jenkins
RUN curl -O https://get.jenkins.io/war-stable/2.303.2/jenkins.war && chmod 777 jenkins.war
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64`

But when trying to run docker build it gives me the following error:

 => ERROR [4/6] RUN curl -O https://get.jenkins.io/war-stable/2.303.2/jenkins.war && chmod 777 jenkins.war                                                   0.7s
------                                                                                                                                                            
 > [4/6] RUN curl -O https://get.jenkins.io/war-stable/2.303.2/jenkins.war && chmod 777 jenkins.war:                                                              
0.283   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                                                             
0.286                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
0.718 Warning: Failed to open the file jenkins.war: Permission denied
------
Dockerfile:16
--------------------
  14 |     
  15 |     USER jenkins
  16 | >>> RUN curl -O https://get.jenkins.io/war-stable/2.303.2/jenkins.war && chmod 777 jenkins.war
  17 |     COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
  18 |     RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt
--------------------
ERROR: failed to solve: process "/bin/sh -c curl -O https://get.jenkins.io/war-stable/2.303.2/jenkins.war && chmod 777 jenkins.war" did not complete successfully: exit code: 23

I would need some solution other than permission, which as you can see, I already run chmod in the command, and it still doesn't work

0

There are 0 answers