I'm trying to access an HTTP proxy from a container that was created using docker in docker. I'm doing this on a Kubernetes worker that still has docker available. This is what my deployment looks like,
apiVersion: apps/v1
kind: Deployment
metadata:
name: alpine
labels:
app: alpine
spec:
replicas: 1
selector:
matchLabels:
app: alpine
template:
metadata:
labels:
app: alpine
spec:
containers:
- name: alpine
image: alpine:3
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
volumeMounts:
- name: docker-socket
mountPath: /var/run/docker.sock
volumes:
- name: docker-socket
hostPath:
path: /var/run/docker.sock
It's a simple Deployment
using the official alpine:3
image. The worker has docker installed so I'm able to mount in the docker.sock
file.
Now I exec into that Alpine 3 pod/container so that I can install docker
. I cannot install the package or run apk update
until I set the proxy environment variables: HTTP_PROXY
, HTTPS_PROXY
, and NO_PROXY
. Once those are set I'm able to update apk and install the docker
package.
Now that docker
is installed I run another container using,
docker run -it --rm alpine:3 sh
Now I have a shell in this new Alpine 3 container. Again I cannot run apk update
because I am behind an HTTP proxy. So I set the three environment variables again. But this time I still cannot run apk update
or apk add curl
or access the internet as I was in the host container.
Does anyone know why I cannot use the HTTP proxy in a container started from within another? Or what I may be missing to make this work? I spent the better of a day searching the internet and discussing with coworkers but cannot find a solution. Many thanks.