我有一个运行以下docker-compose
文件的实例:
version: '3.6'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: '135.181.27.5'
container_name: 'gitlab'
#environment:
# GITLAB_OMNIBUS_CONFIG: |
# external_url 'http://135.181.27.5'
# # Add any other gitlab.rb configuration here, each on its own line
ports:
- '80:80'
- '443:443'
- '222:22'
volumes:
- '/var/gitlab/config:/etc/gitlab'
- '/var/gitlab/logs:/var/log/gitlab'
- '/var/gitlab/data:/var/opt/gitlab'
shm_size: '256m'
我将端口22映射到222,因为端口22是我用来访问服务器的
一切都很好,但当我向gitlab实例添加公共ssh密钥并尝试通过以下命令克隆repo时:
git clone git@135.181.27.5:root/python-demo-cicd.git
结果是:
Cloning into 'python-demo-cicd'...
git@135.181.27.5's password:
问题是端口从22映射到222吗?如果是,那么我如何使用端口222而不是22来实现git目的?
git clone git@host:path/to/repo.git
的默认ssh端口是22,使用不同的端口更改为git clone ssh://git@host:222/path/to/repo
。
你可以将它添加到你的~/.ssh/config
中,以继续使用短git@host
,但这对其他人来说不太合适。。。
match host 135.181.27.5 user git
port 222