# Docker Unable to proxy outside container

**URL:** <https://forums.docker.com/t/docker-unable-to-proxy-outside-container/136696>\
**Category:** Docker Hub\
**Tags:** docker\
**Created:** [July 5, 2023, 3:45am UTC](https://forums.docker.com/t/docker-unable-to-proxy-outside-container/136696 "2023-07-05T03:45:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lexnov](https://avatars.discourse-cdn.com/v4/letter/l/5e9695/32.png) [@lexnov](https://forums.docker.com/u/lexnov)\
**Post date:** [July 5, 2023, 3:45am UTC](https://forums.docker.com/t/docker-unable-to-proxy-outside-container/136696/1 "2023-07-05T03:45:32Z")

</div>

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](http://www.google.com) --proxy [http://0.0.0.0:3128](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”

---

<div class="post-metadata">

**Author:** ![garylavayou](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/garylavayou/32/39937_2.png) [@garylavayou](https://forums.docker.com/u/garylavayou)\
**Post date:** [December 12, 2023, 3:58am UTC](https://forums.docker.com/t/docker-unable-to-proxy-outside-container/136696/2 "2023-12-12T03:58:15Z")

</div>

> [@lexnov](#):
>
> 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](http://www.google.com) --proxy [http://0.0.0.0:3128](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,

The proxy settings should use the proxy host (WSL)'s IP address, like, `"172.31.102.5"`, i.e., the address of the `eth0` interface (see it using `"ip a"` command).  
`0.0.0.0` will be resolved to the build container’s own address during the building procedure. Hence, the proxy setting is invalid.
