Docker Unable to proxy outside container

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 --proxy 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
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 :// Could not connect to ( - connect (111: Connection refused)
W: Failed to fetch http :// Unable to connect to
W: Failed to fetch http :// Unable to connect to
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 ://’
export https_proxy=‘http ://’

and ~/.docker/config.json
“httpProxy”: “http ://”,
“httpsProxy”: “http ://”

and /etc/environment
HTTP_PROXY=“http ://”
HTTPS_PROXY=“http ://”

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