Mike730
Mike730

Reputation: 595

Build docker image on windows | proxy issue

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:

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]

Upvotes: 1

Views: 1127

Answers (1)

Mike730
Mike730

Reputation: 595

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.

Upvotes: 1

Related Questions