Use Docker to make a mirror and push it to the mirror warehouse

This article will tell you how to use docker to download a mirror from the remote end, then modify the mirror, and finally push the mirror to your own mirror warehouse

1. Install Docker

There is nothing to say about this, just download the corresponding installation package and install it according to your own environment

docker官网下载地址 Home - Docker​​​​​​Learn how Atomist will help Docker meet the challenge of securing secure software supply chains for development teams.https://www.docker.com/

Note that Macs distinguish between chips, and the correct version must be downloaded. Regardless of the Linux, Mac or Windows version of Docker, you can use the docker command to operate on the command line. I think the command line is more concise than the desktop program, so the following examples use the command line to operate.

2. Mirror image production

You can choose to create a mirror image from scratch, but there is little point in reinventing the wheel. I choose to download the ready-made mirror image from the mirror warehouse, and add my own needs to create a new mirror image.

2.1 Pull the image from the mirror warehouse

Before using docker to perform pull and push operations, you need to log in first, and you must log in to the corresponding image

Login account: username is the prefix of the mailbox, login password: the password set before

docker login -u g*********n -p ********* iregistry.-int.com

Pull the image from the mirror repository

# 从镜像仓库拉取镜像
docker pull iregistry.-int.com/ubuntu_android/ubuntu-android:1.0.1
# 查看本地镜像文件
docker images

 As you can see, the remote mirror has been pulled to the local 

2.2 Modify and create a mirror image

First, you need to use the tag command to tag someone else’s image and make the repository your own.

# 第一个参数是原有镜像的image id 第二个参数是新镜像的仓库地址:自定义版本号
docker tag af25f4ae69d6 iregistry.-int.com/test-oem/oem-android:0.1

 At this point, I have cloned my own image with someone else's image, and the next step is to modify the image, such as adding the software I need, or related to the compilation environment.

The first is to start and enter the image, first check the local image, run the image through the docker run command, and then enter the image for operation

docker run -it iregistry.-int.com/test-oem/oem-android:0.1 /bin/bash

Then create a buildkit folder in the home directory. Note that you cannot exit before the modification is submitted. Once you exit, all operations are gone. 

 Next, you need to submit the changes, and you need to open a command line window

# 产看当前运行的镜像
docker ps
CONTAINER ID   IMAGE                                                   COMMAND       CREATED          STATUS          PORTS     NAMES
172d77a8211f   iregistry.-int.com/test-oem/oem-android:0.1   "/bin/bash"   15 seconds ago   Up 15 seconds             frosty_maxwell
# 提交之前的修改 -m表示修改的内容  -a表示修改者  之后是容器ID,最后是仓库地址和版本
docker commit -m "test mkdir" -a "********" 172d77a8211f iregistry.-int.com/test-oem/oem-android:0.2
sha256:5f173bdf3f47f8a614129cfa4f43face370e68c37481f48aafe8254a6a71f41f
# 查看所有镜像,可以看到,多了一个镜像文件
docker images
REPOSITORY                                              TAG       IMAGE ID       CREATED          SIZE
iregistry.-int.com/test-oem/oem-android       0.2       5f173bdf3f47   11 seconds ago   1.19GB
iregistry.-int.com/ubuntu_android/ubuntu-android   1.0.1     af25f4ae69d6   9 months ago     1.19GB
iregistry.-int.com/test-oem/oem-android       0.1       af25f4ae69d6   9 months ago     1.19GB

Then enter the new image view in the previous window, and you can see that the previous operations are retained

# 启动0.2版本的镜像
docker run -it iregistry.-int.com/test-oem/oem-android:0.2 /bin/bash                                  
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
root@cd8ca67f4e45:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@cd8ca67f4e45:/# cd home
root@cd8ca67f4e45:/home# ls
buildkit  work

Of course, creating a folder is just an example, you can also do other things, such as downloading Android's compilation environment related

The main purpose of using nohup is to not block you from executing other commands. After executing the command, press Enter to exit. You can do other things, which is very useful.

# wget下载jdk1.8.141
nohup wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz" &

# gradle 下载官网  https://gradle.org/releases/
nohup wget https://downloads.gradle-dn.com/distributions/gradle-6.7.1-all.zip &

# Android buildtools下载官网 https://androidsdkmanager.azurewebsites.net/Buildtools
nohup wget https://dl.google.com/android/repository/build-tools_r23.0.3-linux.zip &

# ndk下载官网
# https://developer.android.google.cn/ndk/downloads/
# https://github.com/android/ndk/wiki/Unsupported-Downloads
nohup wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip &

2.3 Push the image to the warehouse

After the local image modification and submission are completed, you can submit the image you made to the image warehouse, just use docker push

docker push iregistry.-int.com/test-oem/oem-android:0.1

 

Then go to the remote warehouse to check, and you can see your mirror image 

some skills

1. Transfer the local file to the docker image

 2. Some operations of docker

1. 删除容器
docker ps #查看正在运行的容器
docker ps -a #查看所有容器
docker rm container_id #删除容器

2. 删除镜像
docker images //查看镜像
docker rmi image_id

Original codewords are not easy, if it is helpful to you, please give it a thumbs up!

Guess you like

Origin blog.csdn.net/guo_zhen_qian/article/details/126956290