yum update / apk update / apt-get update not working behind proxy

时间秒杀一切 提交于 2019-12-06 03:14:44

For CentOS, I explicitly had to enter my proxy port 80 and remove the http://-part. So for CentOS, a working solution looks like this (if proxy is running on port 80):

FROM centos

ENV http_proxy=<My-PROXY>:80
ENV https_proxy=<My-PROXY>:80

RUN yum update

Alpine is still missing, it looks like it requires additional line:

ENV HTTP_PROXY_AUTH=basic:*:<USER>:<PASS>

but is not working for me. It may be because of special chars inside my password, see: https://github.com/gliderlabs/docker-alpine/issues/305

I will update this answer if I find a solution.

Edit: For alpine, I use this:

FROM alpine

ENV http_proxy=http://<My-PROXY>:80/
ENV https_proxy=http://<My-PROXY>:80/

RUN apk update

We have faced the same issue with alpine and apk update. After all solution appears trivial. It looks like apk needs uppercase proxy variables and http:// segment in proxy server address

FROM alpine:3.8

ENV HTTP_PROXY http://proxyserver:proxyport
ENV HTTPS_PROXY http://proxyserver:proxyport

RUN apk update \
    && apk add bash

This solved the problem for us.

Did you set the ENV http_proxy instructions after the RUN apt-get update instruction?

They should be set before they're used, as docker builds the image from the dockerfile from top to bottom.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!