docker-compose - 使用 Docker-Compose 文件安装 GitLab-CE - Ssh git 用户询问密码
问题描述
Docker-Compose file
我已经在我的 Docker 主机服务器上使用以下链接成功安装了 GitLab-CE 版本。
https://docs.gitlab.com/omnibus/docker/#install-gitlab-using-docker-compose
我的docker-compose.yml
内容如下。
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
gitlab_rails['gitlab_shell_ssh_port'] = 2223
ports:
- '80:80'
- '443:443'
- '2223:22'
volumes:
- '$GITLAB_HOME/gitlab/config:/etc/gitlab'
- '$GITLAB_HOME/gitlab/logs:/var/log/gitlab'
- '$GITLAB_HOME/gitlab/data:/var/opt/gitlab'
在我的一个 Ubuntu 客户端系统中,当我运行ssh -T -p 2223 git@gitlab.example.com
它时它可以工作(它显示Welcome to GitLab
)。gitlab_rails['gitlab_shell_ssh_port'] = 2223
而在我的 docker 主机中,如果我gitlab.rb
在运行gitlab-ctl reconfigure
. 如果我再次运行ssh -T git@gitlab.example.com
它,它会询问git
用户的密码。
Docker-Server 的 22 端口监听如下。
netstat -tulnp | grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1516/sshd
tcp6 0 0 :::2222 :::* LISTEN 2587/docker-proxy
tcp6 0 0 :::22 :::* LISTEN 1516/sshd
由于sshd
服务已经22
在我的 docker 服务器上的端口上运行,那么有没有办法使用 22 默认端口来克隆我们的 GitLab 存储库?无需更改 sshd 默认端口。就像下面的示例命令一样,我想克隆。所以任何建议都会有所帮助。
git clone git@gitlab.example.com:sample-group/sample.git
@Exadra37,我已经更新了您共享的数据并尝试重建,但它失败了。
[root@gitlab]# docker-compose up --build
WARNING: The SSH_AUTH_SOCK variable is not set. Defaulting to a blank string.
Recreating 486bb3cb8496_docker-gitlab-ce_web_1 ... error
ERROR: for 486bb3cb8496_docker-gitlab-ce_web_1 Cannot create container for service web: create .: volume name is too short, names should be at least two alphanumeric characters
ERROR: for web Cannot create container for service web: create .: volume name is too short, names should be at least two alphanumeric characters
ERROR: Encountered errors while bringing up the project.
解决方案
您需要将 ssh 套接字映射到容器中。
将以下内容添加到您的docker-compose.yml
文件中:
environment:
- SSH_AUTH_SOCK=/ssh-agent
volumes:
- $SSH_AUTH_SOCK:/ssh-agent
推荐阅读
- python - Django 查询集 - 查找两个查询集之间的百分比
- sql - 在 SQL Developer 中设置时间范围
- php - 用 withcount 和 orderby 分块巨大的查询
- python - 处理熊猫路径的最佳方法
- node.js - 接吻的消息顺序 - whatsapp
- azure-data-studio - Azure Data Studio - 分离结果窗口
- c# - 无法显示TreeView的所有节点
- python - 使用 numpy.where() 进行矢量化
- python - pandas binning via cut 包括单值(零)bin
- django - ValueError:“封面”属性没有与之关联的文件