Docker Community Forums

Share and learn in the Docker community.

Issue with Getting Started guide when behind proxy


(Imcdermott) #1

Hi all,
I’m trying out the getting started guide and on step 2 I am getting an error when running the “docker build -t friendlyhello .” command:
I’ve created the dockerfile as specified,

# Use an official Python runtime as a parent image
FROM python:2.7-slim

ENV http_proxy http://myproxyname:8080
ENV https_proxy http://myproxyname:8080

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

It proceeds through some of the steps before it hits a connection issue, it is able to get python etc so clearly it is using the proxy to some extent, but it seems like Python can’t pick up the proxy. Here’s the complete output:

Sending build context to Docker daemon   5.12kB
Step 1/9 : FROM python:2.7-slim
 ---> 52ad41c7aea4
Step 2/9 : ENV http_proxy http://myproxyname:8080
 ---> Using cache
 ---> 62721c9d89be
Step 3/9 : ENV https_proxy http://myproxyname:8080
 ---> Using cache
 ---> f7f4cecfe249
Step 4/9 : WORKDIR /app
 ---> Using cache
 ---> 042ca42faa06
Step 5/9 : ADD . /app
 ---> Using cache
 ---> ac5c9e811542
Step 6/9 : RUN pip install --trusted-host pypi.python.org -r requirements.txt
 ---> Running in 11f37feb0788
Collecting Flask (from -r requirements.txt (line 1))
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe197d1d3d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))': /simple/flask/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe197d1d5d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))': /simple/flask/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe197d1db90>: Failed to establish a new connection: [Errno -2] Name or service not known',))': /simple/flask/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe197d1d350>: Failed to establish a new connection: [Errno -2] Name or service not known',))': /simple/flask/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fe19821ffd0>: Failed to establish a new connection: [Errno -2] Name or service not known',))': /simple/flask/
  Could not find a version that satisfies the requirement Flask (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for Flask (from -r requirements.txt (line 1))

I am on High Sierra 10.13.3, I have configured the proxy environment variables in my bashrc file and also in the docker app(17.12.0-ce-mac55). Can you please let me know if there are other steps I am missing? This worked for me when I was not behind my work proxy.