Update deployment
with:
Make container privileged.
securityContext:
privileged: true
Create a VolumeMount
for /var/run/docker.sock
volumeMounts:
- mountPath: /tmp
name: tmp
- mountPath: /var/jenkins_home
name: jenkins-home
- mountPath: /var/jenkins_config
name: jenkins-config
readOnly: true
- mountPath: /usr/share/jenkins/ref/secrets/
name: secrets-dir
- mountPath: /usr/share/jenkins/ref/plugins/
name: plugin-dir
- mountPath: /var/run/docker.sock
name: docker-socket-volume
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: jenkins-token-v4m4w
readOnly: true
Create hostpath
volume
to location of docker.sock
on host vm. e.g. /var/vcap/sys/run/docker/docker.sock
volumes:
- emptyDir: {}
name: plugins
- emptyDir: {}
name: tmp
- configMap:
defaultMode: 420
name: jenkins
name: jenkins-config
- emptyDir: {}
name: secrets-dir
- emptyDir: {}
name: plugin-dir
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins
- hostPath:
path: /var/vcap/sys/run/docker/docker.sock
type: File
name: docker-socket-volume
- name: jenkins-token-v4m4w
secret:
defaultMode: 420
secretName: jenkins-token-v4m4w
Ensure POD is redeployed.
Jenkins example pipeline usage:
cp /var/jenkins_home/workspace/spring-boot-service/target/gs-rest-service-0.1.0.jar /var/jenkins_home/workspace/spring-boot-service/
docker build -t harbor.run.pivotal.io/myrepo/spring-boot-service . --build-arg JAR_FILE=gs-rest-service-0.1.0.jar
docker login https://harbor.run.pivotal.io/myrepo -u $HARBOR_USERNAME -p $HARBOR_PASSWORD
docker push harbor.run.pez.pivotal.io/myrepo/spring-boot-service
Note that the
jar
must be copied to the same directory as theDockerfile
so it's packaged and provided to the docker daemon on the host vm.