# How to generate a docker with the desired plugins installed

**URL:** <https://community.jenkins.io/t/how-to-generate-a-docker-with-the-desired-plugins-installed/3453>\
**Category:** Using Jenkins\
**Created:** [August 22, 2022, 10:46am UTC](https://community.jenkins.io/t/how-to-generate-a-docker-with-the-desired-plugins-installed/3453 "2022-08-22T10:46:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apalomer](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/apalomer/32/2988_2.png) [@apalomer](https://community.jenkins.io/u/apalomer)\
**Post date:** [August 22, 2022, 10:46am UTC](https://community.jenkins.io/t/how-to-generate-a-docker-with-the-desired-plugins-installed/3453/1 "2022-08-22T10:46:32Z")

</div>

Hello, I had a docker file to generate a docker image with the desired plugins installed. That docker file was using `install-plugins.sh` script. But after I downloaded the latest jenkins docker image, it has stoped working and gives me the following error: `install-plugins.sh has been removed, please switch to jenkins-plugin-cli`  
But I have not been able to see how to run the jenkins cli during docker build. Could anybody provide a small dockerfile example so I can build my docker with the desired plugins?

My current dockerfile is the follwoing:

```auto
FROM jenkins/jenkins:lts-jdk11
LABEL maintainer="my-email@my-domain.com"
ENV JENKINS_USER my_user
ENV JENKINS_PASS my_password
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=true
RUN /usr/local/bin/install-plugins.sh bitbucket-build-status-notifier atlassian-jira-software-cloud docker-plugin docker-workflow blueocean

```

Thank you very much.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [August 22, 2022, 12:10pm UTC](https://community.jenkins.io/t/how-to-generate-a-docker-with-the-desired-plugins-installed/3453/2 "2022-08-22T12:10:10Z")

</div>

The Jenkins documentation for [installing Jenkins with Docker](https://www.jenkins.io/doc/book/installing/docker/#on-macos-and-linux) includes a snippet like the following example Dockerfile:

```nohighlight
FROM jenkins/jenkins:2.346.3-jdk11
RUN jenkins-plugin-cli --plugins "blueocean:1.25.6 docker-workflow:1.29"

```

More details are available at:

> **[Docker](https://www.jenkins.io/doc/book/installing/docker/#on-macos-and-linux)**
>
> Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

The [Jenkins 2.346.2 upgrade guide](https://www.jenkins.io/doc/upgrade-guide/2.346/#upgrading-to-jenkins-lts-2-346-2) also notes that `install-plugins.sh` has been replaced.

---

<div class="post-metadata">

**Author:** ![vpoptani](https://avatars.discourse-cdn.com/v4/letter/v/85e7bf/32.png) [@vpoptani](https://community.jenkins.io/u/vpoptani)\
**Post date:** [March 15, 2023, 8:05am UTC](https://community.jenkins.io/t/how-to-generate-a-docker-with-the-desired-plugins-installed/3453/3 "2023-03-15T08:05:37Z")

</div>

I am trying this approach using a dockerfile but facing issue with plugins update site. I am using a plugins.txt file. I have tried from my client machine which is behind a proxy and also from my EC2 instance, EC2 doesn’t have any proxies, i am getting the same issues from both the servers.

Dockerfile:

```auto
FROM jenkins/jenkins:lts-jdk11

COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt

#RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt

RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt && \
echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state

```

Error Logs:

```auto
Step 4/4 : RUN jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt && echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state
 ---> Running in 1dc5712c294c
Mar 15, 2023 8:00:27 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {s}->https://updates.jenkins.io:443: The target server failed to respond
Mar 15, 2023 8:00:27 AM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {s}->https://updates.jenkins.io:443
Killed
The command '/bin/sh -c jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.txt && echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state' returned a non-zero code: 137

```
