[英]Unable to clone repository in docker-compose
I'm trying to configure an app to run on localstack using docker-compose.我正在尝试使用 docker-compose 将应用程序配置为在 localstack 上运行。 I'm getting an error when attempting to clone the resository.
尝试克隆资源库时出现错误。
setup-resources_1 | make[1]: [/app/ProjectRecipes.mk:35: clean] Error 2 (ignored)
setup-resources_1 | ServiceName=Tests make -C /app/ -f /app/ProjectRecipes.mk deploy
setup-resources_1 | git clone https://github.com/MyGithOrg/TestProject /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject
setup-resources_1 | Cloning into '/Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject'...
localstack_1 | Waiting for all LocalStack services to be ready
setup-resources_1 | fatal: could not read Username for 'https://github.com': No such device or address
setup-resources_1 | make[4]: *** [/app/ProjectRecipes.mk:24: /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject] Error 128
version: '3'
services:
localstack:
image: localstack/localstack
ports:
- "53:53"
- "443:443"
- "4510-4520:4510-4520"
- "4566-4620:4566-4620"
- "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
environment:
- LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY}
- SERVICES=serverless,rds,lambda,sqs,dynamodb,s3,apigateway,stepfunctions,cloudformation,appsync,firehose,es
- DEBUG=1
- DATA_DIR=/tmp/localstack/data
- DOCKER_HOST=unix:///var/run/docker.sock
- HOST_TMP_FOLDER=${TMPDIR}
volumes:
- "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
- default
setup-resources:
image: golang:1.16.4-alpine3.13
entrypoint: /bin/sh -c
working_dir: /app
command: >
"
ls
apk add --update alpine-sdk
make Tests
"
networks:
- default
volumes:
- type: bind
source: ~/go
target: /go
- type: bind
source: ${HOME}
target: /root
- type: bind
source: .
target: /app
- ~/.ssh:/root/.ssh
- ~/.gitconfig:/root/.gitconfig
depends_on:
- localstack
The following command fails in your container because it is an interactive command that expects the user to enter username
and password
for GitHub.以下命令在您的容器中失败,因为它是一个交互式命令,需要用户输入 GitHub 的用户
username
和password
。 Although this is not the case in your local machine, that is the case inside the container.尽管在您的本地计算机中不是这种情况,但容器内部就是这种情况。 I don't know the reason for the difference.
我不知道差异的原因。
git clone https://github.com/MyGithOrg/TestProject /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject
You can clone your repository through SSH using the following command:您可以使用以下命令通过 SSH 克隆您的存储库:
git clone ssh://git@github.com/MyGithOrg/TestProject.git /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject
Update your clone command to use SSH like above.更新您的克隆命令以使用 SSH,如上所示。
If you haven't configured an SSH key in your Github profile, you can follow this documentation to do so.如果您尚未在 Github 配置文件中配置 SSH 密钥,则可以按照此文档进行操作。
⚠️ Make sure at this step you are able to clone the repo using SSH in your local machine.
⚠️ 确保在此步骤中您能够在本地机器上使用 SSH 克隆 repo。
Update your command
in docker-compose file to install an SSH client更新 docker-compose 文件中的
command
以安装 SSH 客户端
command: > " ls apk add --update alpine-sdk openssh make Tests "
If you're using a Mac, then make sure you have IgnoreUnknown UseKeychain
above UseKeychain yes
in your ~/.ssh/config
file.如果您使用的是 Mac,请确保在
~/.ssh/config
文件中的UseKeychain yes
上方有IgnoreUnknown UseKeychain
。
ℹ️ The reason is that
openssh
version that is being installed in your Golang Alpine image does not recognizeUseKeychain
option and will throw youBad configuration option: usekeychain
error.ℹ️ 原因是你的 Golang Alpine 镜像中安装的
openssh
版本无法识别UseKeychain
选项,会抛出Bad configuration option: usekeychain
错误。 You can read more about that in this document .您可以在本文档中阅读更多相关信息。
Example of a correct ~/.ssh/config
file:正确的
~/.ssh/config
文件示例:
Host * AddKeysToAgent yes IgnoreUnknown UseKeychain UseKeychain yes IdentityFile ~/.ssh/id_rsa
Then update your volumes
like below:然后更新您的
volumes
,如下所示:
volumes: - type: bind source: ~/go target: /go - type: bind source: . target: /app - ~/.ssh:/root/.ssh
Note that you no longer need ~/.gitconfig:/root/.gitconfig
volume.请注意,您不再需要
~/.gitconfig:/root/.gitconfig
卷。 I also removed your mapping of HOME
directory to /root
of the container because I still doubt that it might cause issues.我还删除了您将
HOME
目录映射到容器的/root
,因为我仍然怀疑它可能会导致问题。
I believe this should work for you now.我相信这现在应该对你有用。 Cheers !!!
干杯!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.