Overview I have been using Docker for more than a year. Recently, I realized that when I was quickly orchestrating services, the git used in the shell script was still native. So I decided to containerize git, searched on dockerhub, and found this image with a relatively high download volume After looking at the dockerfile, I feel that it is not suitable for the needs There are no volumes or ssh provided here. It is not possible to map the repository to the host machine, nor is there a function to clone a private repository (whisper: both are possible, but inconvenient). Other gitclient images are similar.
Mirror address The image in this article is pushed to dockerhub. You can use it directly if needed: https://hub.docker.com/r/wuliangxue/git wheel First, you need a Docker Hub account, and then log in to the server using Docker to push the image to the Docker Hub repository, which will facilitate future migrations. Create a git.dockerfile file in any directory In the Dockerfile, enter the following Let me briefly explain here that originally a mirror based on Ubuntu 18.04 was provided, but the size was too large, so it was replaced with Alpine. Domestic users need to switch the Linux software source to a domestic mirror, otherwise various problems will arise when installing the software. This image itself is for cloning projects, so only git and ssh are installed. The following is to prepare for cloning the private warehouse and open the corresponding ssh directory volume. Since the working directory is set, the default project is in the Build the image Enter the command: When Successfully appears, it means the image is built successfully. Here we compare the sizes of images built based on Ubuntu 18.04. The image with the tag 0.1 is built based on Ubuntu 18.04 [187M], and the image with the tag 0.1-alpine is built based on alpine:3.12 [30.1M] Using Mirror First, use the image you just built to clone a public repository and execute the following command docker run --rm --name git \ -v "$(pwd)":/git/repo wuliangxue/git:0.1-alpine \ git clone https://github.com/docker-library/mysql.git This repository has been cloned. If you want to view the details of the clone, you can add docker run -it --rm --name git \ -v "$(pwd)":/git/repo wuliangxue/git:0.1-alpine \ git clone https://github.com/docker-library/mysql.git What should I do when I need to clone a private warehouse? ? docker run -it --rm --name git \ -v "$(pwd)":/git/repo \ -v "$(pwd)/id_rsa":/root/.ssh/id_rsa \ -v "$(pwd)/id_rsa.pub":/root/.ssh/id_rsa.pub \ wuliangxue/git:0.1-alpine git clone [email protected]:wuliangxue/douyu.git Note that the Enter yes and press Enter to clone the private warehouse. Finally, push this wheel to Dockerhub so that you can directly pull it and use it next time you change the server. This is the end of this article about using Docker to build a Git image using clone repository. For more information about Docker building Git image, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: HTML table tag tutorial (20): row background color attribute BGCOLOR
>>: Native JS implementation of loading progress bar
Table of contents 1. Install Docker 2. Create a c...
Important note: Before studying this article, you...
The effect to be achieved: When the mouse is plac...
Table of contents 1. Configure bridging and captu...
Since I have parsed HTML before, I want to use Vu...
1 CSS style without semicolon ";" 2 Tags...
Table of contents Explanation of v-text on if for...
Table of contents 1. concat() 2. join() 3. push()...
This article summarizes the common commands for L...
one. Preface <br />You will see this kind of...
Software Download Download software link: https:/...
This article example shares the specific code of ...
What is the input type="file"? I don'...
Table of contents Install Importing components Ba...
reduce method is an array iteration method. Unlik...