# Configure docker image chef/chefworkstation

**URL:** <https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644>\
**Category:** Chef Workstation\
**Created:** [December 9, 2023, 2:00pm UTC](https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644 "2023-12-09T14:00:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartv](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bartv/32/3458_2.png) [@bartv](https://discourse.chef.io/u/bartv)\
**Post date:** [December 9, 2023, 2:00pm UTC](https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644/1 "2023-12-09T14:00:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [December 11, 2023, 5:10pm UTC](https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644/2 "2023-12-11T17:10:56Z")

</div>

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.

```auto
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 {

```

---

<div class="post-metadata">

**Author:** ![bartv](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bartv/32/3458_2.png) [@bartv](https://discourse.chef.io/u/bartv)\
**Post date:** [December 11, 2023, 7:47pm UTC](https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644/3 "2023-12-11T19:47:37Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [December 11, 2023, 8:00pm UTC](https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644/4 "2023-12-11T20:00:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mbaitelman](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mbaitelman](https://discourse.chef.io/u/mbaitelman)\
**Post date:** [December 11, 2023, 8:18pm UTC](https://discourse.chef.io/t/configure-docker-image-chef-chefworkstation/22644/5 "2023-12-11T20:18:46Z")

</div>

Take a look at this repo [GitHub - mbaitelman/chef-policy-cookbook](https://github.com/mbaitelman/chef-policy-cookbook)  
it handles it for chefdk for uploading policies etc
