Cannot get Jenkins Docker slave to build docker images

I am currently experimenting with Docker in combination with Jenkins to streamline the CI/CD workflow for a new project. I do so on a Mac with Docker 1.12 installed.

This is what I do:

  • Visual Studio 2015 - Missing Publish to Docker option
  • What is cloudfront link?
  • Running docker chrome node in EC2 Does Not Download Files
  • Running angular2 webpack app with busybox httpd in docker
  • Passing a docker container's generated name to another container in docker-compose
  • Cannot connect to localhost with Rocketchat on Docker
    1. Use docker machine to create a new Docker server
    2. Use the official Jenkins Docker image to spin up a Jenkins instance on that server
    3. Install the “Yet Another Docker Plugin” and “CloudBees Docker Pipeline” plugins.
    4. Add a “Docker Cloud” using the IP of the Docker server above and the third party Docker DinD image tehranian/dind-jenkins-slave

    With this setup, I run a very simple pipeline job like this:

    node('docker') {
        docker.image('hseeberger/scala-sbt').inside {
            stage 'Checkout'
            echo 'We got here!'

    Jenkins spins up a Docker instance as expected and executes the job. So the basic Docker setup is working as expected.

    But the Docker command within the job fails. Log output looks something like this:

    [Pipeline] node
    Still waiting to schedule task
    Docker-23ebf3d8dd4f is offline
    Running on Docker-23ebf3d8dd4f in /home/jenkins/workspace/docker-test
    [Pipeline] {
    [Pipeline] sh
    [docker-test] Running shell script
    + docker inspect -f . hseeberger/scala-sbt
    Cannot connect to the Docker daemon. Is the docker daemon running on this host?
    [Pipeline] sh
    [docker-test] Running shell script
    + docker pull hseeberger/scala-sbt
    Using default tag: latest
    Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default:
    Cannot connect to the Docker daemon. Is the docker daemon running on this host?
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline

    Now when I browse around for solutions, it is usually mentioned that the Docker socket needs to be provided to the container as a volume, but that doesn’t seem to work either.

    Since the general setup seems to be working, wouldn’t the slave simply have to do the same thing as the Jenkins plugin does to spin up the Docker slave in the first place? That is, use the URL of the Docker server to control it? Since I assume this is an extremely common use-case, there must be a Docker image for Jenkins Docker slaves that can do this out of the box, right? What am I missing?

  • Can we use docker-image with the hyperkit driver on a mac?
  • Cannot login with wp-cli generated user wordpress behind reverse proxy
  • How to run node.js on port 80 inside Docker
  • Mount a volume while using a docker container in Azure App Service
  • How to convert a Vagrantfile to a Dockerfile
  • docker AWS fail to launch - custom kernel
  • One Solution collect form web for “Cannot get Jenkins Docker slave to build docker images”

    You might need to set the docker env and use the content of docker-machine env node in your running shellscript.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.