Running docker.withserver within docker.inside

564 views
Skip to first unread message

Johan Abelsson

unread,
Apr 27, 2017, 6:57:19 AM4/27/17
to Jenkins Users
I want to connect to another docker daemon from within a docker container but it's not working from within jenkins.

The error I get is:

[restart_portal] Running shell script
Error response from daemon: No such container: 5a0fce9025ba1d047d8da9718ab830222d3fdc9f2a38773efd1e9d117f7e1e79

Is there a workaround for this?



Here is a simple example:

scripted:

docker.image('myimage').inside {
docker.withServer('tcp://10.11.11.109:2376', 'my-docker-creds'){
sh 'docker ps'
}
}


declarative:

pipeline {
        agent {
          dockerfile {
            filename "jenkinsfiles/restart_portal/Dockerfile.aws"
            label "restart"            
          }
  
    stages {
      stage('connect to docker host') {
        }
        steps {          
          script {
            docker.withServer('tcp://10.11.11.109:2376', 'my-docker-creds'){
              sh "docker ps"  
            }
            
          }
        }            
      }
    }
}
Reply all
Reply to author
Forward
0 new messages