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 Common array methods pop() unsh...
The knowledge points summarized below are all fre...
Table of contents App.vue sub1.vue sub2.vue Summa...
1. Overview The image in Docker is designed in la...
Table of contents Preface Hello World image Set b...
Solution to Host 'xxxx' is not allowed to...
Preface Due to the weak typing of JS, loose writi...
1. Introduction The difference between row locks ...
This article shares the specific code of Vue usin...
Preface Recently, our company has configured mbp,...
Here we take the Jenkins container as an example ...
Table of contents Introduction Get started A brie...
<body style="scroll:no"> <tabl...
Canal is an open source project under Alibaba, de...
During the project optimization today, MySQL had ...