Tell me please.
I'm using Jenkins to build a project that runs in a docker container and I've run into a problem.
When executing this piece of code:
stage('deploy front') {
when { equals expected: 'do', actual: buildFront }
agent {docker{image 'ebiwd/alpine-ssh'}}
steps{
sh 'chmod 400 .iac/privatekey'
sh "ssh -i .iac/privatekey [email protected]"
}
}
I get an error:
ssh -i .iac/privatekey [email protected]
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '134.209.181.163' (ECDSA) to the list of known hosts.
bind: No such file or directory
unix_listener: cannot bind to path: /root/.ssh/sockets/[email protected]
Moreover, if you execute the following script with your hands in the container, then everything works
ssh -i .iac/privatekey [email protected]
container with Jenkins started with docker-compose.yaml
version: '3.1'
services:
jenkins:
image: jenkins/jenkins:2.277.1-lts
container_name: jenkins
hostname: jenkins
restart: always
user: root
privileged: true
ports:
- 172.17.0.1:8070:8080
- 50000:50000
volumes:
- /opt/docker/jenkins/home:/var/jenkins_home
- /etc/timezone:/etc/timezone
- /usr/bin/docker:/usr/bin/docker
- /etc/localtime:/etc/localtime
- /var/run/docker.sock:/var/run/docker.sock
What could be the problem?
CodePudding user response:
I have the same error in my Gitlab pipelines:
bind: No such file or directory
unix_listener: cannot bind to path: /root/.ssh/sockets/[email protected]
lost connection
I think that the error is related to this changeset.
In particular, the ssh config file requires the path "~/.ssh/sockets" to be present. Since we are not using the script /usr/local/bin/add-ssh-key (custom script created for that image) this path is missing.
I've opened an issue in the image project: Error using the image in CI/CD pipelines #10.
CodePudding user response:
The problem was at this place:
agent {docker{image 'ebiwd/alpine-ssh'}}
When i change it to prev version, like:
agent {docker{image 'ebiwd/alpine-ssh:3.13'}}
Everything started working