docker-alpine: apk update/add in the docker container under proxy giving permission denied
Running docker in a host (centos Red Hat Enterprise Linux Server release 7.2 (Maipo)) which is under proxy, able to pull alpine:3.4 by following steps in stackoverflow.
Now starting the container form alpine:3.4, setting proxy, and running apk --update add curl giving me permission denied
[root@xxx ~]# docker run -it alpine:3.4 sh
/ # export http_proxy=http://proxyuser:proxypassword@proxyip:proxyport
/ # export https_proxy=http://proxyuser:proxypassword@proxyip:proxyport
/ # apk --update add curl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.4/main: Permission denied
WARNING: Ignoring APKINDEX.167438ca.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.4/community: Permission denied
WARNING: Ignoring APKINDEX.a2e6dac0.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
curl (missing):
required by: world[curl]
/ #
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 26
- Comments: 40 (1 by maintainers)
Closing as it sounds like the workaround here is to set
HTTP_PROXY_AUTH=basic:*:proxyuser:proxypassas well as your normal proxy information.Same issue without using a proxy! Alpine is such a pain…
After several attempts with several combinations, I found the magic solution :
HTTP_PROXY_AUTH=basic:*:proxy_user:proxy_passwordHTTP_PROXY=http://proxy_host:proxy_portHTTPS_PROXY=http://proxy_host:proxy_portMy password contains the @ character, I left it as it is.It seems that apk uses libfetch, which accepts HTTP_PROXY_AUTH environment variable. I could workaround this issue as following:
Please note that upper case letters must be used for HTTP_PROXY_AUTH .
@kiranpradeep
apk add --no-cache straceUnfortunately this workaround can’t be used if the proxy server does not accept any authentication credentials. In my environment, behind a coorporate firewall, I can’t get it to work as I cannot use
HTTP_PROXY_AUTH🤷I tried this and saw that, it is just the
apktool that is failing. When I triedwgetonalpine:3.4docker container under proxy,wgetsucceeds. Butapktool continue giving permission denied error. Does theapktool under alpine, honor http_proxy/https_proxy environment variables ?I’ve tried it and got the same solution.
ng1
apk can’t resolve the proxy host name without percent-encoding.
ng2
Probably libfetch does not support percent-encoding.
see: libfetch/http.c
ok
docker build
Got something similar with the nginx:alpine image :
Error Result :
I don’t understand. The “solutions” are not working for us. We still get permission denied, no matter what we try.
@unoexperto you’ve probably solved your issue by now but this may be useful to someone else.
I had a similar issue also on EC2, running Docker 17.06.0-ce.
To troubleshoot, I tried wget in my Dockerfile
wget http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gzbut got 403s as well, then instead of tryingI then switched to HTTPS and tried
wget https://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gzand that worked after I turned the SSL certificate check off.However
https://dl-3.alpinelinux.orghad a valid certificate so I set that as my repository in my Dockerfile.RUN echo 'https://dl-3.alpinelinux.org/alpine/v3.4/main' > /etc/apk/repositoriesHowever, while attempting to
apk install --no-cache --update nodejsI got the following warning and errorSo I added testing and community repositories like so
Everything worked happily after that.
All in all problems should have been fix with specifying
--build-args http_proxy="$http_proxy" --build-args https_proxy="$https_proxy"for $docker build, withhttp_proxyandhttps_proxydefined in /etc/environment on the host system.Except I ran into the situation where
http_proxyandhttps_proxycontained special characters in the username and password fields. Something like:http://userlocation\username:password@proxy.xyz:80(notably the “\”) and needed to be defined as:http://userlocation%5Cusername:password@proxy.xyz:80(notably the “%5C”)This worked on the host system (ubuntu), but apk did not support this, and vice-versa.
Problem was fixed by defining
http_proxy_unescapedandhttps_proxy_unescapedand passing these to $docker build. eg.--build-args http_proxy="$http_proxy_unescaped" --build-args https_proxy="$https_proxy_unescaped"sudo -E keeps your environment variables.
Come back to that issue. The work around doens’t work when no authentication is requried at proxy side. I m running over docker 1.12.1 (I see docker info | grep Security => seccomp). Running strace fails with also Operation not permitted. My guess is something goes wrong with security options, but how to deal with ?
I still get the sequences : docker run -it alpine:3.3 sh apk update fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz ^C wget http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz Connecting to dl-cdn.alpinelinux.org (151.101.44.249:80) ^C / # export http_proxy=http://proxyhost:proxyport / # export https_proxy=http://proxyhost:proxyport / # wget http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz Connecting to proxy (proxy) APKINDEX.tar.gz 100% / # apk update fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.3/main: Permission denied / strace apk update strace: ptrace(PTRACE_TRACEME, …): Operation not permitted
Someone was able to use this image with https proxy?
docker run -v /apk/addons:/custo --security-opt seccomp:unconfined --cap-add SYS_PTRACE -e http_proxy=http://proxyhost:proxyport -e https_proxy=http://proxyhost:proxyport -it alpine:3.3 sh /# apk add /custo/strace-4.13-r0.apk /# strace apk update => get a 407 . The mistake comes with the proxy i was using. Just to close the thread adding the tip for running strace over 1.12 docker.
In my case I was able to avoid this error after disconnecting from my company’s VPN
same problem for golang image with
add in Dockerfile
worked
The issue is precisely the same, but the environmental circumstances are different. I’m getting the same error, but the solution is not feasible for my case. What to do? Open a new issue ticket which will be closed because everyone assumes it must be the proxy to which a solution was given here in this thread? Please instruct…
It appears that apk only honours the HTTP_PROXY variable and not http_proxy. So your environment variable has to be all caps. Same for HTTPS_PROXY. Do not use small case proxy environment variable here.
Hi all - I’m sure all involved have moved on, but in case someone else finds this - this might also help (in addition to what @omoloro mentioned above)
I encountered this issue on our Google Cloud Compute instance running ubuntu 17.04. None of the fixes here helped, so I decided to see if the same thing happens on Centos 7 - and it worked on first try!
We don’t use any proxy server ourselves, but I imagine that running in a VM inside a cloud would mean that there’s some kind of proxy along the path in their infrastructure. In any case, I’m assuming there’s something in Ubuntu’s configuration (not necessarily related to Docker) that [indirectly] causes this.