1

I am trying to install curl from within a docker container and it fails with the following error, I tried to set proxy - No go

steps tried:

  • docker build using Dockerfile

  • docker build using build args HTTP_PROXY

  • docker login to repo and then try to build image - no go

  • update config.json file with env proxies - no go

  • use a different proxy

  • attempted to flush DNS on windows pc

  • docker build pass the env context

  • change docker desktop settings For Web Server and Secure Web Server, enter: proxy

  • Bypass proxy settings, enter localhost - Apply & Restart docker desktop - no go

Please advise further - thank you

$ docker run -ti --env HTTPS_PROXY="<my_proxy>" alpine:latest - works and I can get in.

# apk add --no-cache curl 
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz 
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: Permission denied 
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz 
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: temporary error (try again later) 
ERROR: unable to select packages: 
  curl (no such package): 
    required by: world[curl]
Mike730
  • 495
  • 1
  • 5
  • 14

1 Answers1

1

Download certificate: example.crt

Copy example.crt to /etc/ssl/certs/example.crt within the container

Add the contents of example.crt to /etc/ssl/certs/ca-certificates.crt

cat /etc/ssl/certs/example.crt >> /etc/ssl/certs/ca-certificates.crt

set the environment HTTPS_PROXY variable to http://{proxy}:{port}

export HTTPS_PROXY=http://{proxy}:{port}

Run apk update or install other packages from external resources

Dockerfile

 FROM alpine:latest

 # This could also be passed as a build argument
 ENV HTTPS_PROXY=http://{proxy}:{port}

 COPY example.crt /etc/ssl/certs/example.crt
 RUN cat /etc/ssl/certs/example.crt >> /etc/ssl/certs/ca-certificates.crt

 RUN apk update

This resolved the issue.

Mike730
  • 495
  • 1
  • 5
  • 14