我正在嘗試使用 docker-compose 將應用配置為在 localstack 上運行。我在嘗試克隆存儲庫時遇到錯誤。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 deploysetup-resources_1 | git clone https://github.com/MyGithOrg/TestProject /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProjectsetup-resources_1 | Cloning into '/Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject'...localstack_1 | Waiting for all LocalStack services to be readysetup-resources_1 | fatal: could not read Username for 'https://github.com': No such device or addresssetup-resources_1 | make[4]: *** [/app/ProjectRecipes.mk:24: /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject] Error 128docker-compose.ymlversion: '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
1 回答

慕田峪7331174
TA貢獻1828條經驗 獲得超13個贊
問題:
以下命令在容器中失敗,因為它是一個交互式命令,需要用戶輸入 GitHub 和 GitHub。盡管在本地計算機中并非如此,但在容器內就是這種情況。我不知道差異??的原因。username
password
git clone https://github.com/MyGithOrg/TestProject /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject
溶液:
您可以使用以下命令通過 SSH 克隆存儲庫:
git clone ssh://[email protected]/MyGithOrg/TestProject.git /Users/antarr.byrd/go/src/github.com/MyGithOrg/TestProject
步驟:
如上所述,更新克隆命令以使用 SSH。
如果尚未在 Github 配置文件中配置 SSH 密鑰,則可以按照此文檔進行操作。
?? 確保在此步驟中,能夠在本地計算機中使用 SSH 克隆存儲庫。
更新 docker-compose 文件中以安裝 SSH 客戶端
command
command: > " ls apk add --update alpine-sdk openssh make Tests "
如果您使用的是 Mac,請確保您的文件中有上述內容。
IgnoreUnknown UseKeychain
UseKeychain yes
~/.ssh/config
i? 原因是Golang Alpine映像中安裝的版本無法識別選項,并會拋出錯誤。您可以在本文檔中閱讀有關此內容的更多信息。
openssh
UseKeychain
Bad configuration option: usekeychain
正確文件的示例:
~/.ssh/config
Host * AddKeysToAgent yes IgnoreUnknown UseKeychain UseKeychain yes IdentityFile ~/.ssh/id_rsa
然后更新您的喜歡以下內容:
volumes
volumes: - type: bind source: ~/go target: /go - type: bind source: . target: /app - ~/.ssh:/root/.ssh
請注意,您不再需要卷。我還刪除了將目錄映射到容器,因為我仍然懷疑它是否可能導致問題。
~/.gitconfig:/root/.gitconfig
HOME
/root
我相信這現在應該對你有用。干杯??!!!
- 1 回答
- 0 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消