Some Docker images, such as those used to build Kubernetes clusters, cannot be downloaded in the country for undescribed reasons.

This article is to teach you how to download these Docker images in China smoothly.

So how do you do that?

Here we mainly use the “container mirror service” provided by Ali Cloud, which not only provides the hosting ability of the image, but also provides the domestic and foreign image construction services, and also free.

Note that this article is not the same thing as the “container image acceleration” provided by Ali Cloud. Acceleration is to solve the problem of slow speed, provided it can be accessed. This article deals with images that are inaccessible in the country for reasons that cannot be described (such as k8s.gcr. IO /kube-apiserver).

One sentence explanation: using the container image service provided by Ali Cloud, build our own Docker image.

FROM K8s. GCR. IO/kube - apiserver: v1.17.3
MAINTAINER yourname <[email protected]>
Copy the code

See?

If you do not understand, you can follow my steps to operate again, a total of only two steps, including the church.

K8s.gcr. IO /kube-apiserver:v1.17.3 is used as an example.

Step 1: Create the repository on GitHub

You can refer to my github.com/heqingbao/d… Create Dockerfile under kube-apiserver:

FROM K8s. GCR. IO/kube - apiserver: v1.17.3
MAINTAINER yourname <[email protected]>
Copy the code

Step 2: Ali Cloud to create a mirror warehouse

Log in to Ali Cloud image service

2.1 Creating a namespace

Create a namespace with “default repository type” public or private. I’m private here. For example, I call k8S-docker-image-mirror here, as shown in figure:

2.2 Creating an Image Repository

Select k8S-docker-image-mirror (k8S-docker-image-mirror), kube-apiserver (k8S-docker-image-mirror), kube-apiserver (k8s-docker-image-mirror), kube-apiserver (k8s-docker-image-mirror), kube-apiserver (k8s-docker-image-mirror), kube-apiserver (k8s-docker-image-mirror)

Click “Next” to associate the code repository. Here, select GitHub and associate the code repository created on GitHub in the first step:

As you can see, there are many other options available besides GitHub, and if GitHub is too difficult to access, you can choose another type.

If you select “Overseas Machine Build”, you can leave the check box for the first automatic build image unchecked. You can change the check box later when configuring the build policy.

Then click create Mirror Warehouse

2.3 Adding a Build Rule

This step is to configure the build rules, such as branch names, Dockerfile paths, and so on, as shown in the figure below:

Enter the build page and click “Add Rule”, as shown in the picture:

Add a build rule as shown:

As above, the content can be modified according to the situation.

2.4 Building an Image

After creating the build rule, click “Build Now”, as shown below:

Wait for a moment and see that the build status is successful, it means that the build is complete, as shown in figure:

2.5 Obtaining a Mirror

Image build complete, start to get the image, as shown below:

Follow the above instructions. For example, HERE I can obtain:

docker pull registry.cn-shenzhen.aliyuncs.com/k8s-docker-image-mirror/kube-apiserver:latest
Copy the code

You can try it. It’s fast.

Note that the password required for the first step docker login is not the login password of Aliyun, but is set here separately:

For example, if you want to build a K8s cluster, you need to change the image Tag to:

Docker tag registry.cn-hangzhou.aliyuncs.com/k8s-docker-image-mirror/kube-apiserver k8s. GCR. IO/kube - apiserver: v1.17.3Copy the code

In theory, it is possible to build any foreign walled mirror in this way. For example, I built all mirrors of the K8s cluster in this way, as shown in the figure below:

That’s it. Did you learn? (Won’t watch it again)


Recommended to follow the public account: non-famous developers, subscribe to more content