Configure Git environment in DockerAt work, I encountered a scenario where I needed to operate a GitLab repository in a Docker environment, so I needed to set up the Git environment in Docker in advance. Since the operation of Git repository in Docker is fully automated, it is necessary to pull the repository and submit operations without password. I use SSH to perform password-free operations here. So the first thing is to configure SSH, and the second is to configure the Docker environment. Configure SSH KeyFirst generate SSH key: ssh-agent eval $(ssh-agent -s) ssh-keygen -o -t rsa -b 4096 -C "{username}" ssh-add ~/.ssh/id_rsa //Add to .bashrc Go to the GitLab page and log in, then select Settings. Select SSH Keys in the left navigation bar. Copy the previously generated public key Then click Add key: In this way, the SSH public key is bound to the GitLab user, and the user can be used to perform password-free operations on the Git repository in the future. Configure Docker environmentFirst, copy the private key to the same directory as the Dockerfile (assuming there is a Dockerfile in the project), and then configure the Dockerfile. # configure ssh environment for gitlab RUN mkdir -p /root/.ssh COPY id_rsa /root/.ssh/ RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config \ && echo "UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config RUN git config --global user.email "[email protected]" \ && git config --global user.name "username" Just insert this code into it. For user.email and user.name, use the account number that configured GitLab SSH Key before. At this point, you can operate the Git repository in Docker without password. Possible ErrorsIf the following errors still exist: This indicates RUN chown 1000:1000 /root/.ssh/id_rsa The problem is solved. This concludes this article about the process of setting up and configuring the Git environment in Docker. For more information about configuring the Git environment with Docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL series 9 MySQL query cache and index
>>: A brief analysis of the four import methods and priorities in CSS
Use "onInput(event)" to detect whether ...
This article describes how to configure a seconda...
Implementation requirements The form imitating El...
Create a new project test1 on Code Cloud Enter th...
This article uses examples to illustrate how to i...
mysql permissions and indexes The highest user of...
DML operations refer to operations on table recor...
When I was looking at some CSS3 animation source ...
Table of contents Preface Why introduce unit test...
After I found that the previous article solved th...
Cocos Creator version: 2.3.4 Demo download: https...
1. Download the accelerated version of msyql dock...
1. Download address https://dev.mysql.com/downloa...
In the horizontal direction, you can set the row ...
This article shares the specific code for JavaScr...