【发布时间】:2020-08-14 21:50:16
【问题描述】:
我在将 ssh-agent 转发到 docker 容器(使用我的 docker-compose 安装)时遇到了严重的麻烦。我有运行 Catalina 的 Mac,使用 docker-engine 19.03.8 和 Compose @ 1.24。 以下是我的 docker-compose 文件:
version: '3.7'
services:
platform:
build:
context: .
dockerfile: ./platform/compose/Dockerfile.platform.local
working_dir: /root/platform
ports:
- "3000:3000"
command: ["./compose/scripts/start_rails.sh"]
tty: true
stdin_open: true
volumes:
- type: bind
source: /run/host-services/ssh-auth.sock
target: /run/host-services/ssh-auth.sock
env_file: ./platform/.env
environment:
TERM: xterm-256color
SSH_AUTH_SOCK: /run/host-services/ssh-auth.sock
volumes:
我配置ssh-agent转发的方式是docker-compose documentation指定的
./compose/scripts/start_rails.sh 脚本执行bundle install && bundle exec rails s。我从私有存储库中提取的 gem 很少,我认为我应该能够通过转发 ssh-agent 来安装这些 gem。
我也尝试在启动 docker-compose 之前启动 ssh-agent,但这似乎没有任何作用。
{
"debug": true,
"experimental": true,
"features": {
"buildkit": true
}
}
这是我在 docker 配置文件中添加的内容。任何帮助表示赞赏。
**更新:0 **
我的 .ssh 目录结构和配置如下:
树 ~/.ssh
├── config
├── known_hosts
├── midhun
│ ├── id_rsa
│ └── id_rsa.pub
└── client
├── id_rsa
└── id_rsa.pub
猫 ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/client/id_rsa
Host me.github.com
HostName github.com
User git
IdentityFile ~/.ssh/midhun/id_rsa
更新:1
用ForwardAgent Yes 更新了我的配置,但它也不起作用。我已经在这个 gist 中记录了整个 ssh 日志 -> https://gist.github.com/midhunkrishna/8f77ebdc90c7230d2ffae0834dc477cc 。
【问题讨论】:
-
不清楚你想达到什么目的?
-
尝试将 ssh-agent 转发到正在运行的 docker 容器中,这样当我运行
bundle install时,bundler 可以从私有仓库中提取 gem。 -
请在您的两个条目中添加
ForwardAgent yes,看看是否有效
标签: ruby-on-rails docker docker-compose ssh-agent moby