Recently I just faced some network issues when building up docker images on our AWS Bastion. The
docker build command cannot pick up the environment variable for network proxy.
Network Issue with Docker Build
When I used
curl -i https://registry.docker.io to check the network, everything looks OK. But when I was trying to build the docker image via
docker build -t nba ./ and it raised the following Timeout error.
Looks like docker daemon cannot reach out to the docker registry. The solution proposed at here didn’t work to me.
Then I found the
page from offical Docker document. So basically I need to setup a
/etc/systemd/system/docker.service.d/http-proxy.conf file and specify the proxy setting there.
After setup those, it’s better to restart the docker daemon and docker service to let the daemon pick up the latest configuration.
To check the configuration we can use
Network Issue with Pip in Docker Image
Now it’s OK to build docker images. But then there is another network issue for install python libraries via
To solve this problem, we need to specify the
--build-arg arguments and add the HTTP_PROXY and HTTPS_PROXY variables in the docker build command.
The complete docker build image will looks like
Until then the docker image can be happily built with no errors.