I am using a WSL2 (Ubuntu-20.04) setup to run docker (v24.0.2)
In this particular environment I am not able to access the internet unless through proxy.
WSL2 has no problems connecting via
Curl http://www.google.com --proxy http://0.0.0.0:3128 or sudo apt update
when I run below commands
Docker build --tag my-docker-image --file Dockerfile .
Docker run -it --rm --name my-docker-container-wsl my-docker-image
Dockerfile contains
FROM PERIL:5.32
CMD [“bash”]
I am brough into the container in a bash terminal, but as soon as I type.
apt update
W: Failed to fetch http ://deb.debian.org/debian/dists/bullseye/InRelease Could not connect to 0.0.0.0:3128 (0.0.0.0). - connect (111: Connection refused)
W: Failed to fetch http ://deb.debian.org/debian-security/dists/bullseye-security/InRelease Unable to connect to 0.0.0.0:3128:
W: Failed to fetch http ://deb.debian.org/debian/dists/bullseye-updates/InRelease Unable to connect to 0.0.0.0:3128:
W: Some index files failed to download. They have been ignored, or old ones used instead.
I am at a bit of a loss why Linux is able to use the proxy but the docker container is being denied permissions.
I would like to mention that i started docker using
sudo service docker start
==additional info==
I have modifed /etc/default/docker with
export http_proxy=‘http ://0.0.0.0:3128’
export https_proxy=‘http ://0.0.0.0:3128’
and ~/.docker/config.json
{
“proxies”:
{
“default”:
{
“httpProxy”: “http ://0.0.0.0:3128”,
“httpsProxy”: “http ://0.0.0.0:3128”
}
}
}
and /etc/environment
HTTP_PROXY=“http ://0.0.0.0:3128”
HTTPS_PROXY=“http ://0.0.0.0:3128”