How to enable proxy with Docker on Linux with systemd
Docker and systemd are software solutions which probably don’t follow rules, best practices and UNIX standards available and respected for ages.
Almost every Linux software is aware of http_proxy and https_proxy environment variables. In case network access is restricted and only available via authenticating proxy common pattern is Cntlm. If you use wget on affected host then wget checks http_proxy environment variables. In case you use Firefox it also respects env. Docker is different. It has got dedicated article how to setup http proxy: https://docs.docker.com/network/proxy/#configure-the-docker-client. Unfortunatelly none of these things work.
Docker command line tool interacts with Docker service. Docker command binary probably cannot send configuration to Docker service, so even when http_proxy is set then it’s not used by the Docker service pulling images. Does Docker service read /etc/profile to check if http_proxy is set? No. Docker service uses HTTP_PROXY environment variable which should be set in systemd service definition.

For building image you need additional command line arguments:
docker build -t app:latest . --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy
This may be one of many reasons why we have CRI-O, Buildah and Podman. I bet they follow UNIX standards known are respected for ages.