Detailed explanation of using Alibaba Cloud image repository to build foreign Docker images

Detailed explanation of using Alibaba Cloud image repository to build foreign Docker images

Download foreign images using Alibaba Cloud Image Repository

In the daily use of Docker or K8S, you often need to download images from foreign websites, but some websites are not accessible in China. To solve this problem, you can use the image repository provided by Alibaba Cloud to download it, then pull it to your local computer and modify the tag to implement it.

For example, when deploying Istio using K8S, you need to download the gcr.io/istio-testing/install-cni:1.5-dev image. You can build and download it in Alibaba Cloud according to the following steps:

1. Configure Github

First log in to Github and create a repository for building images, for example, named image-build

Create a folder on your local computer, for example, named dockerImage

Enter the dockerImage directory and clone the repository in Github to your local machine.

https://github.com/CoderX-Aaron/image-build.git

After cloning is complete, enter the image-build directory and create a Dockerfile named install-cni with the following content:

FROM gcr.io/istio-testing/install-cni:1.5-dev

Submit the Dockerfile file you just created to git and specify the branch name as master (modify it according to the default first branch name when creating a repository in Github)

git add install-cni
git commit -m "Create Dockerfile to build install-cni image"
git branch -M master

Push the content in git to Github:

git push -u origin master

2. Configure Alibaba Cloud

The steps to configure the image repository and build in Alibaba Cloud are as follows:

Log in to the Alibaba Cloud console and enter the container image service

Click on代碼源in the left tab and bind your Github account

After the binding is completed, click the image repository in the left tab to start creating the namespace, repository name and summary information, and click Next

Select Github in the code source, CoderX-Aaron (that is, the username of Github) in the namespace, and image-build in the repository. In the build settings below, check海外機器構建, then click Create Mirror Repository

After creating the repository, click Manage Repository and select Build in the left tab. First, set up a new build rule in the build rules. Pay attention to the path and file name of the Dockerfile directory, which should be consistent with that in Github.

After creating the build rule, click the "Build Now" button behind the corresponding rule to start building the image.

3. Pull the image

After the image is built successfully, you can see the built image in the "Image Version" tab. Next, pull the image to the local computer. The steps are as follows:

First, log in to the Alibaba Cloud Mirror Repository in the command line of the local machine. The username used for login is the full name of the Alibaba Cloud account, and the password is the password set when activating the service.

docker login --username=username registry.cn-hangzhou.aliyuncs.com

Pull the image from the registry to the local

docker pull registry.cn-hangzhou.aliyuncs.com/ops-docker/istio:v1

Modify the image tag

docker tag registry.cn-hangzhou.aliyuncs.com/ops-docker/istio:v1 gcr.io/istio-testing/install-cni:1.5-dev

This completes the download of the install-cni image and changes the image pull policy in K8S to IfNotPresent or Never .

4. Push the image to Alibaba Cloud

To push a local image to Alibaba Cloud, you first need to modify the tag of the local image:

docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/ops-docker/istio:[image version number]

Next, push the image:

docker push registry.cn-hangzhou.aliyuncs.com/ops-docker/istio:[image version number]

This concludes this article on how to use Alibaba Cloud's image repository to build foreign Docker images. For more information about how to build foreign Docker images on Alibaba Cloud, please search for previous articles on 123WORDPRESS.COM or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to build a docker local image warehouse under centos7 system
  • Tutorial on how to create a private image repository with Docker
  • How to use domestic image warehouse for Docker
  • Implementation of Docker configuration modification of Alibaba Cloud image repository
  • .NETCore Docker implements containerization and private image repository management
  • Steps for Docker to build its own local image repository
  • Example of setting up a private Docker image repository on a CentOS 7.2 server
  • Detailed explanation of building a Docker private image repository based on Harbor
  • How to use Alibaba Cloud image repository with Docker
  • How to build a private image repository with Docker
  • How to use Docker image repository

<<:  Detailed explanation of explain type in MySQL

>>:  Install nodejs and yarn and configure Taobao source process record

Recommend

Overview of MySQL Statistics

MySQL executes SQL through the process of SQL par...

Vue image cropping component example code

Example: tip: This component is based on vue-crop...

Solution to the problem of MySQL thread in Opening tables

Problem Description Recently, there was a MySQL5....

Solution to the automatic termination of docker run container

Today I encountered a problem when I used Dockerf...

Semantic web pages XHTML semantic markup

Another important aspect of separating structure ...

Simple usage examples of MySQL custom functions

This article uses examples to illustrate the usag...

MySQL 5.7.17 installation and configuration method graphic tutorial (windows)

1. Download the software 1. Go to the MySQL offic...

30 free high-quality English ribbon fonts

30 free high-quality English ribbon fonts for down...

MySQL 5.7 installation and configuration tutorial

This article shares the MySQL installation and co...

Three ways to communicate between Docker containers

We all know that Docker containers are isolated f...

Three methods of automatically completing commands in MySQL database

Note: The third method is only used in XSell and ...

Vue uses better-scroll to achieve horizontal scrolling method example

1. Implementation principle of scrolling The scro...