Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在gitlab ci中使用ssh将docker编写到远程主机失败_Docker_Ssh_Docker Compose_Gitlab_Gitlab Ci - Fatal编程技术网

在gitlab ci中使用ssh将docker编写到远程主机失败

在gitlab ci中使用ssh将docker编写到远程主机失败,docker,ssh,docker-compose,gitlab,gitlab-ci,Docker,Ssh,Docker Compose,Gitlab,Gitlab Ci,我无法从gitlab CI/CD管道运行程序使用SSH在远程主机上成功docker compose docker compose失败,出现以下错误: http.client.RemoteDisconnected: Remote end closed connection without response urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed c

我无法从gitlab CI/CD管道运行程序使用SSH在远程主机上成功docker compose

docker compose失败,出现以下错误:

http.client.RemoteDisconnected: Remote end closed connection without response
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
我无法在Gitlab之外重新处理这个问题。也就是说,我在本地机器上尝试运行gitlab部署步骤使用的相同docker映像,手动在脚本中执行完全相同的命令,效果非常好

我甚至在脚本中尝试ssh配置,通过连接到主机并打印
docker版本
,它成功了

将_部署到_staging.sh gitlab-ci.yml
谢谢你的帮助

你找到问题所在了吗?我也有类似的问题。@kodlan不幸的是没有。我无法在Gitlab之外复制此问题,所以我被卡住了。。。
#!/bin/bash

apk update
apk add openssh-client
apk add --update bash

eval $(ssh-agent -s)
mkdir -p ~/.ssh
chmod 600 ~/.ssh
# copy the server private key
echo "$SSH_PRIVATE_KEY"
echo "$SSH_PRIVATE_KEY" | ssh-add -
# copy server host key .pub file from /etc/ssh/ and paste it into this variable
echo "$SSH_SERVER_HOSTKEYS"
ssh-keyscan -p 12345 11.222.3.444
ssh-keyscan -p 12345 11.222.3.444 >> ~/.ssh/known_hosts

ssh root@11.222.3.444 -p 12345 "docker version; exit"

# Docker-compose app and db
docker-compose --verbose -H "ssh://root@11.222.3.444:12345" -f docker-compose.staging.yml up -d --build

exit
image: alpine:latest

services:
  - docker:dind

stages:
  - build
  - package
  - deploy

[...]

deploy:
  image: docker/compose:alpine-1.28.2
  stage: deploy
  environment:
    name: staging
  only:
    - master
  script:
    - sh deploy_to_staging.sh