Docker Registry local image warehouse combined with intranet penetration to achieve remote pull and push images

Docker Registry local image warehouse, combine a few simple steps with the cpolar intranet penetration tool to achieve remote pull or push (pull and push) images, without being restricted by the local LAN!

1. Deploy Docker Registry

Use the official website installation method and start the docker command with one click. This command starts a registry container. The version is 2. The mounting host port is port 5000. After mounting, port 5000 is the local port we use to connect to the mirror warehouse.

docker run -d -p 5000:5000 --name registry registry:2

After execution, enter docker ps and we can see the running container

2. Test push image locally

After Docker Registry runs normally, the local test pushes an image to the Registry. Here, the test pushes the local mysql image:

Tag the image

docker image tag mysql localhost:5000/myfirstimage

push

docker push localhost:5000/myfirstimage

You can see that the push is successful. Pushing the image locally to Docker Registry indicates success. Next, install the cpolar intranet penetration tool to achieve remote push.

3. Linux installation cpolar

Above we have successfully installed the Docker Registry local image library. Next we install the cpolar intranet penetration tool on Linux and forward the http public network address mapped by the local port through cpolar. We can easily achieve remote connections without registering a domain name ourselves and purchasing a cloud. Server. The following are the steps to install cpolar

cpolar official website address: https://www.cpolar.com

  • Use one-click script installation command
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • Add services to the system
sudo systemctl enable cpolar
  • Start cpolar service
sudo systemctl start cpolar

After cpolar is successfully installed, access Linux port 9200 on an external browser: [http://LAN ip:9200]. Log in using your cpolar account. After logging in, you can see the cpolar web configuration interface, which is connected to the web management interface. Just configure

4. Configure Docker Registry public network access address

Click Tunnel Management - Create Tunnel on the left dashboard to create a Docker Registry http cpolar public network address tunnel!

  • Tunnel name: You can customize the name. Be careful not to duplicate the existing tunnel name.
  • Protocol: Select http
  • Local address: 5000
  • Domain name type: Choose a random domain name for free
  • Region: Select China vip

Click创建

image-20230920140230036

After the tunnel is successfully created, click the status on the left - online tunnel list to view the generated public network access address. There are two access methods, one is http and https

image-20230920140536614

5. Remote push to Docker Registry over public network

Docker Registry needs to use https for push. The cpolar domain name supports https access by default, so it is more convenient and does not require us to set anything else.

First mark the image, and then push it. Note that https://the protocol name does not need to be entered. You can see that the push is successful, and a remote connection with a public network address is set up!

image-20230920143908566

You can also pull it

image-20230920144311368

6. Fixed Docker Registry public network address

Since the tunnel created using cpolar above uses a random public network address, it will change randomly within 24 hours, which is not conducive to long-term remote access. Therefore, we can configure a second-level subdomain name for it. This address is a fixed address and will not change randomly [ps: cpolar.cn has been filed]

Note that you need to upgrade the cpolar package to a basic package or above, and the bandwidth corresponding to each package is different. [cpolar.cn has been registered]

Log in to the cpolar official website , click Reserve on the left, select to reserve the second-level subdomain name, set a second-level subdomain name, click Reserve, and copy the reserved second-level subdomain name after the reservation is successful.

image-20230920144725353

After the reservation is successful, copy the name of the second-level subdomain name that was successfully reserved.

image-20230920144830077

Return to the cpolar web UI management interface, click Tunnel Management - Tunnel List on the left dashboard, find the tunnel you want to configure, and click Edit on the right

image-20230920150527018

Modify the tunnel information and configure the successfully reserved second-level subdomain name into the tunnel.

  • Domain name type: Select a second-level subdomain name
  • Sub Domain: Fill in the successfully reserved second-level subdomain name

Click 更新(note, click once to update, no need to submit again)

image-20230920150711591

After the update is completed, open the online tunnel list. At this time, you can see that the public network address has changed and the address name has become a domain name with a fixed second-level subdomain name.

Test again using a fixed address for remote control. You can see that it is successful. In this way, a fixed and permanent public network address is set.

image-20230920155453247

Guess you like

Origin blog.csdn.net/m0_73868817/article/details/135352378