There are three situations for adding an agent to docker:
- Add proxy for docker pull (dockerd)
- Add proxy for Docker build
- Add proxy to docker container
Reference articles are as follows:
Among them, if you do not want to write the running command in plain text in the startup script when using the proxy address, you can store the user name and password in environment variables, and pass these two parameters in during execution docker run
.
Add agent to docker build
docker build . -f Dockerfile.frontendapi
-t registry.cn-shanghai.aliyuncs.com/jinq0123/openmatch-frontendapi:dev
–network host
–build-arg HTTP_PROXY=http://127.0.0.1:1080
–build-arg HTTPS_PROXY=http://127.0.0.1:1080
Reminder, you need to use --build-arg
proxy injection, simple ENV
may not be useful.