Introduction
When running docker pull to download images, the process inexplicably halts, and I'm unable to complete the download. This issue was caused by the restrictions imposed by the corporate proxy, which, while protective, can be quite limiting. Fortunately, there is a Private Docker Registry within the corporate network that I can use. I'll document the steps to register images there before I forget.
For instructions on setting up a Private Registry, refer to the following resource:
Below is the explanation using the official Node.js Docker image as an example.
Obtain the Image from an External PC
First, obtain the Docker image on an external PC that is not affected by the corporate proxy. (No such PC? Good luck!!)
# Download the image from Docker Hub (a public registry)
docker pull library/node:10.15.0
# Export the image to a tar file
docker save library/node:10.15.0 > ./image.tar
Copy this image.tar file to an internal PC. (Since the network isn't connected, perhaps via a USB memory stick? The struggle is real.)
Import the Image to an Internal PC
Next, import the Docker image to an internal PC that is within the proxy environment.
# Load the image from the tar file
docker load < ./image.tar
# Display and verify the image list
docker images
All following operations should be performed on the internal PC.
Register the Image with the Private Registry
Next, register the Docker image with the Private Docker Registry inside the network. For this explanation, the address and port of the Private Registry are xxx.xxx.xxx.xxx:xxxx.
# Rename the image
docker tag library/node:10.15.0 xxx.xxx.xxx.xxx:xxxx/library/node:10.15.0
# Push to the Private Registry (in a proxy environment)
docker push xxx.xxx.xxx.xxx:xxxx/library/node:10.15.0
In my environment, an error saying http: server gave HTTP response to HTTPS client occurred. Research revealed that you need to add xxx.xxx.xxx.xxx:xxxx to the insecure registries in the Docker settings on the PC.
For more details, see:
With this, registration to the private registry is complete.
Retrieve the Image from the Private Registry
Simply write it as follows:
# Download the image from the Private Registry
docker pull xxx.xxx.xxx.xxx:xxxx/library/node:10.15.0
Testing on a colleague's PC (an internal PC) confirmed successful image download.
Pull the Image in a Dockerfile
In a Dockerfile, it is just the same.
# Download the image from the Private Registry
FROM xxx.xxx.xxx.xxx:xxxx/library/node:10.15.0
Conclusion
I referred to the following sites. Thank you very much.
Top comments (0)