Jenkins pip timeout

I am trying to download a pip package and it times out… I do have proxy settings set and can download from terminal

Help is highly appreciated!

feels like your docker build isn’t getting its proxy settings. When you say you can build it via terminal, whats different?

when I run pip install (packagename) through terminal it does pass through

It only stops when jenkins tries to pip install,
Is there anyway to set proxy settings on docker build?

You’ll want to configure your docker daemon with the proxy info. Configure Docker to use a proxy server | Docker Documentation

Failing that you want to add your proxy info as a --build-arg (there’s lots of examples online but the above seems cleaner)

1 Like

Docker is already running on proxy, otherwise I would not be able to run jenkins
I do appreciate your help! :slight_smile:

Do you have a second docker install (dind) that some of the guides suggest? That would mean you need to configure that docker server as well

The screenshot you posted is showing a Network issue. If it works in one env and not the other then you need to indentify the differences. One of the common ones is emv variables. People put env configs in bashrc but Jenkins doesn’t load those.

My recommendation is to throw an export/print env in your terminal, inside Jenkins not in the docker build, and a third inside your docker file

Please redirect me if something was misunderstood, Jenkins is quite new to me.

Under system information proxy is set

The command used to run jenkins is
docker run -u 0 --privileged --name jenkins -it -d -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker -v /home/jenkins_home:/var/jenkins_home jenkins/jenkins:latest

Dockerfile contains the following :
FROM python
COPY . /app
COPY requirements.txt requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
CMD [“python”, “flask”]

While docker has its proxy settings accordingly and does work.

This setup works at home but not from my job

So I don’t use a proxy myself (neither personal or work), so I’m just guessing based on what I remember from docker years ago.

So if updating /etc/docker/daemon.json doesn’t work, then my suggestion is setting it via a build arg.

How you specify these build args depends on how your building it, but this is the most straight forward.

sh('docker build --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy}')

Jenkins does seem to be running with the following when the dockerfile is set with
pip install packagename --proxy proxyipandporthere
is there anyway to bypass this? I do not want to state my proxy to be shown for safety reasons.

Everything I read says the changes to daemon.json is the way to go which was my first suggestion to you

Next would be setting ENV inside your dockerfile. There are tricks with multistage dockerfiles that can hide that value.

Thirdly would be the way you got it working which is providing it on the pip install CLI, again you can hide it using multistage dockerfiles.

I recommend the daemon.json route.

Other than that I hear your frustration but I can’t help any additionally as I havnt worked in an environment with a proxy in 5+ years. Hopefully someone else with experience can speak up

1 Like

It does say above that you cannot edit the daemon.json file to use a proxy, it does work with environment variable instead and it is already set for me but still does not work

so the following does give an output containing my proxy

sudo systemctl show --property=Environment docker

I got an example here that only works locally

FROM ubuntu:18.04
RUN echo http proxy: ${http_proxy} ${HTTP_PROXY}
RUN echo https proxy: ${https_proxy} ${HTTPS_PROXY}
RUN apt-get update && apt-get install -y wget
CMD [“wget”, “–spider”, “”]

It does echo correct proxy settings but on jenkins nothing is being given as an output

Jenkins use proxy if some java options are set at start, so could you try to run docker with this:

--env JAVA_OPTS="-Dhttp.proxyHost=yourproxyIpAddress -Dhttp.proxyPort=yourproxyport -Dhttps.proxyHost=yourproxyIpAddress -Dhttps.proxyPort=yourproxyport"

But I don’t know if these settings solve your problem.
Hope this help you.

1 Like

I tried running docker with the command you gave and unfortunately it failed.

It did give me an idea of trying to edit the files manually so I did
docker exec -it {container id} /bin/bash
went over to

and it gave the following output

So it seems like it is already set through java env…

my guess is that its an issue with the pip environment as pip does ask me to install through
pip install packagename --proxy ‘proxy:port’

Any more suggestions? :slight_smile:

Did you try to run your command with:

    --env HTTP_PROXY="http://IPproxy:proxyPort" \
    --env http_proxy="http://IPproxy:proxyPort" \
    --env HTTPS_PROXY="https://IPproxy:proxyPort" \
    --env https_proxy="https://IPproxy:proxyPort" \

In your pipeline did you try to print environment variable to see if these variable are set?

Here’s the output for

sh 'printenv'

When running docker with the
–env variable set

Also it does state a proxy is being used on console output (even when the --env variable is not defined)

I’m sorry, I have no other ideas, maybe someone else. If you can solve it, it would be nice to know how.

Any more ideas? would be highly appreciated! ^^

you need to figure out how to fix the pip error before getting help making the fix work in jenkins.

I still think its HTTPS_PROXY isn’t set, and from your screenshot it doesn’t look to be set. your screenshots have http_proxy and https_proxy. Implementations are supposed to handle both, but not all implementations are the same.

Either way, you need to track down how to fix pip inside the container, then we can help you apply that fix to your jenkins install/job.