Configure docker image chef/chefworkstation

Hello,

I have trouble configuring chefworkstation running in a docker container for use in jenkins pipeline.
I managed to configure knife using a .chef folder in the docker working directory, but chef commands are not working (and I need those for installing & pushing policies)

Thanks,
Bart

you need to do something like this to make the .chef folder accessible to the workspace as jenkins isolates workloads to a workspace folder for security reasons.

pipeline {
  agent {
    docker {
      image 'chef/chefdk:latest'
      args '-u root -v /root/.chef:/var/lib/jenkins/workspace/.chef:ro'
    }
  }
  options {
    timeout(time: 10, unit: 'MINUTES')
    timestamps()
    buildDiscarder(logRotator(numToKeepStr: '2'))
  }
  stages {

Thanks for your response!
I had a mapping to the .chef folder, but chef install commands download the cookbooks to .chefdk/cache. As I split up the chef install and chef push commands in separate Jenkins steps (using docker run --rm commands) I lost the installed (downloaded) cookbooks between steps. I added a volume mapping to .chefdk and all lights went green.
Glad we agree!

Good to know. Thanks for the update. This is old code I had as I haven't used jenkins in years hence the reference to chefdk container vs workstation.