Giving proxy ip, username, password before creating image for docker

Hi there,
I am trying to run automated tests in a docker environment on a webapp and I need http and https proxy to have access. I can give the ip and the credentials to the docker image and it creates the image with the given credentials. My problem is that I am looking for a solution where I could give the credentials to the docker before the image creation, because right now they are in the env file and gets added to the image from there.

Never add credentials to an image, unless you are using Multi-stage build, but the final stage should never contain credentials, because everyone would see that who has access to the image when you push it to a registry. You can mount files to the build containers and load the variables in the RUN instruction

If you don’t want that either, my only idea is running anothe rproxy which has the credentials to the other and use that local proxy url in the build containers which forwards the request to the other one.