Score:0

407 Proxy Authentication Error When Running Python in Docker but *Not* when running from local environment

cn flag

I'm having a peculiar issue. When I make requests running my script on my local machine and go through the (paid and authenticated) proxy, it runs just fine. However, when I containerize the application and attempt to run again, I get the following error:

File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 513, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.myawesomesite.com', port=443): Max retries exceeded with url: /my-url/model?opname=metadata (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))

Let me emphasize my python code is exactly the same, including when it comes to retrieving and utilizing the proxy credentials. The weird thing is that I've been running this same technique for over a year now but now seeing this issue all of a sudden. Is there something different about the way that Docker authenticates to proxies? Anyone have ideas what's causing the problem?

For reference here's my the gist of my DockerFile:

FROM python:3.7.5-slim
WORKDIR /usr/src/app
RUN python3 -m pip install \
        requests \
        mysql-connector \
        pymongo \
        numpy \
        dnspython \
        simple_watchdog_timer
COPY myScript1.py .
COPY mySupportingModule1.py .
ENTRYPOINT ["python3", "myScript1.py"]
cn flag
Sorry, your environment isn't 100% clear - are you connecting to the internet through some kind of private hosted proxy that you pay for? And you're trying to run a script via the same proxy, but in a docker container?
cn flag
No problem thanks for asking. I am making requests through a proxy in the script. When I run the script *outside* the container just from shell it works fine. But when I try to containerize it then just run it on the same machine as a pre-deployment test, I am getting the above error.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.