Getting connection timed out while installing Jenkins plugins through Dockerfile

I am trying to install Jenkins 2.393 version through Dockerfile, I am getting an timed out error while trying to download Plugins. Can someone help me out? Please find the below Dockerfile and Attached error what I am getting. Error I am getting:

Unable to resolve plugin URL, or download plugin ansicolor to file: Connect to [] failed: Connection timed out (Connection timed out)
Tried downloading ansicolor from (attempt 1 of 3)

Hello @Anurag and welcome to this community :wave:

Sometimes, I have the same error too, but most of the times, it is transient.
Your error message indicates that the connection to the Jenkins plugin repository at is timing out. This can happen due to network issues, firewalls, or the server being overloaded.

To troubleshoot the issue, you can try the following steps:

  1. Verify that you can access the plugin repository URL from your Docker container by running the curl command (while being in the container thanks to a docker exec -ti) for example:
$ curl -I

If you see a response with HTTP status code 200, it means that you can access the plugin repository.
2. Check if there are any network issues that may be causing the timeout. You can try running the ping command to see if you can reach the plugin repository:

$ ping

If you see a response from the server, it means that you can reach the server and there is no network issue.
3. If you are behind a firewall or proxy server, make sure that the Docker container is configured to use the appropriate proxy settings. You can set the proxy settings in the Dockerfile using the ENV command, for example:

ENV http_proxy http://your.proxy.server:port
ENV https_proxy http://your.proxy.server:port

Replace your.proxy.server and port with your actual proxy server and port number.
4. Another option is to pre-install the required plugins in the Docker image. You can download the plugins manually from the Jenkins plugin repository and copy them to the Docker image using the COPY command in the Dockerfile. For example:

COPY plugins/ansicolor.hpi /usr/share/jenkins/ref/plugins/

Replace plugins/ansicolor.hpi with the path to the downloaded plugin file, and make sure to update the plugin list in the plugins.txt file.