Charts: [stable/Jenkins] How to run docker commands in agents?

Created on 5 Aug 2018  路  4Comments  路  Source: helm/charts

Is this a request for help?:

Yes

Which chart:
Jenkins

What happened:
I can't run docker commands in steps.
/home/jenkins/workspace/vision_front_new_master-PTH4UDTQVSAS7VICPCO2UFHIE5M6B37LQYLEJT5BMAT36AYX77KA@tmp/durable-e821ca88/script.sh: docker: not found

What you expected to happen:
Can run docker commands

Anything else we need to know:
I tried to create a new Docker image with docker but still not working.

FROM jenkinsci/jnlp-slave:latest
USER root
RUN apt-get -q update && \
    apt-get -q install -y apt-transport-https ca-certificates curl software-properties-common && \
    echo 'deb https://apt.dockerproject.org/repo debian-jessie main' >> /etc/apt/sources.list.d/docker.list && \
    curl https://apt.dockerproject.org/gpg > docker.gpg.key && \
    echo "c836dc13577c6f7c133ad1db1a2ee5f41ad742d11e4ac860d8e658b2b39e6ac1 docker.gpg.key" | sha256sum -c && \
    apt-key add docker.gpg.key && \
    rm docker.gpg.key && \
    apt-get -q update && \
    apt-cache policy docker-engine && \
    apt-get -q install -y docker-engine=1.11.2-0~jessie && \
    service docker start && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

Configuration:

variable "project_id" { default = "project" }
variable "region" { default = "us-central1-a" }

variable "plugins" { default = [
  "kubernetes:1.12.0",
  "workflow-job:2.23",
  "workflow-aggregator:2.5",
  "credentials-binding:1.16",
  "git:3.9.1",
  "blueocean:1.7.1"
]}

provider "google" {
  version = "~> 1.0"
  region  = "${var.region}"
  project = "${var.project_id}"
}

resource "helm_release" "jenkins" {
  name      = "jenkins"
  chart     = "stable/jenkins"

  set {
    name  = "Master.AdminUser"
    value = "user"
  }

  set {
    name  = "Master.AdminPassword"
    value = "password"
  }

  set {
    name = "Master.InstallPlugins"
    value = "{${join(",", var.plugins)}}"
  }

  set {
    name = "Agent.AlwaysPullImage"
    value = true
  }

  set {
    name = "Agent.Image"
    value = "us.gcr.io/project/jenkins-docker-agent"
  }

  set {
    name = "Agent.ImageTag"
    value = "latest"
  }
}

Before posted this question here I tried in Stackoverflow: https://stackoverflow.com/questions/51681713/jenkins-helm-docker-not-found-when-try-to-run-a-test

Most helpful comment

For anyone else that stumbles upon this issue looking for a solution, I recommend looking at the documentation on the 'kubernetes' jenkins plugin that is installed with this helm chart here: https://github.com/jenkinsci/kubernetes-plugin

And at the docker building example here: https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/docker.groovy

All 4 comments

My values.yaml

Master:
  AdminUser: user
  AdminPassword: user
  InstallPlugins:
   - kubernetes:1.12.0
   - workflow-job:2.23
   - workflow-aggregator:2.5
   - credentials-binding:1.16
   - git:3.9.1
   - blueocean:1.7.1 
Agent:
  Image: adriagalin/jenkins-jnlp-slave
  ImageTag: 1.4
  AlwaysPullImage: true
  volumes:
   - type: HostPath
     volumeName: docker-sock
     hostPath: /var/run/docker.sock
     mountPath: /var/run/docker.sock

For anyone else that stumbles upon this issue looking for a solution, I recommend looking at the documentation on the 'kubernetes' jenkins plugin that is installed with this helm chart here: https://github.com/jenkinsci/kubernetes-plugin

And at the docker building example here: https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/docker.groovy

@jwenz723 example link has died, can you give a new one :D

@dinhanhhuy here is a permanent link to the example that I previously linked to: https://github.com/jenkinsci/kubernetes-plugin/blob/b1e268c14d3622fad1a1da7a31993e70b568e523/examples/docker.groovy

Was this page helpful?
0 / 5 - 0 ratings