0%
docker 创建两个centos,一个做为git服务端,一个做为git客户端
1 2 3 4
| docker pull centos:7.8.2003 cat /etc/redhat-release docker run -d --name gits --privileged=true centos:7.8.2003 /usr/sbin/init docker run -itd --name gitc centos:7.8.2003 /bin/bash
|
Git 服务端
1 2 3 4 5 6 7 8 9 10 11 12 13
| docker exec -it gits /bin/bash curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum install -y net-tools yum install -y openssh-server # 安装SSH软件包 systemctl start sshd # 开启 SSH 服务 yum install -y git useradd git passwd git su git mkdir /home/git/test.git && cd /home/git/test.git git init --bare # 输出如下内容,表示成功 # Initialized empty Git repository in /home/git/test.git/
|
Git 客户端(本地)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| docker exec -it gitc bash curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum install -y git ssh-keygen cat ~/.ssh/id_rsa.pub | ssh git@remote-server "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" ssh git@172.17.0.2 -v #进到服务端使用root改.ssh和authorized_keys权限 # chmod 700 /home/git/.ssh/ # chmod 600 /home/git/authorized_keys mkdir -p /home/swapnil/git/project cd /home/swapnil/git/project echo "# init" >> README.md git config --global user.email "你的邮箱" git config --global user.name "你的名字" git add . git commit -m "message" git remote add origin git@172.17.0.2:test.git git push -u origin master
git clone git@172.17.0.2:test.git
|