Answers: <ol>
  <li>There are two ways to run Jenkins builds.
  
  <ol>
  <li>The build node executes the build. In that case, all tools the build needs have to be installed on that node/slave.</li>
  <li>The build is run inside a Docker container (with a build node as host). In that case, the Docker image for the build needs to contain all the tools the build needs, but the Jenkins node doesn't have to.</li>
  </ol></li>
  <li><p>"Kill and run again" as in <code>docker stop $name; docker rm $name; docker run ...</code>? Sure, that deletes all data local to that container.</p>
  
  <ul>
  <li>If you want to stop and restart the same container, use <code>docker stop</code> and <code>docker start</code> instead.</li>
  <li>If you want to carry data over from one container to another, use <a href="https://docs.docker.com/storage/volumes/" rel="nofollow noreferrer">volumes</a>.</li>
  </ul></li>
  <li>If you want to go with 1.1 and you need all your Jenkins nodes to come equipped with a certain set of tools (such as Docker, npm, ...), create your own Docker image for them.</li>
  </ol>
  
Answers: CC BY-SA 4.0
Answers: 2019-02-27T09:22:22.767Z
Answers: 2019-02-27T09:22:22.767Z
Answers: Raphael
Body: <p>I'm trying to configure CI with Jenkins for my private project. Problem:</p>
  
  <ul>
  <li>whenever I start building a pipeline project, it gives me ,,Docker is not found'' error</li>
  <li>whenever I try to work around this by installing npm plugin and running bash script <code>npm install</code> as a build step, I get node/npm not found</li>
  </ul>
  
  <p>Solutions I've found and tried:</p>
  
  <p>According to official Jenkins docker image docs, all one is supposed to do is to mount docker.socket in dockerfile/docker-compose file and it should ,,just'' work (it doesn't) - example: </p>
  
  <pre><code>volumes:
       - /var/run/docker.sock:/var/run/docker.sock
  </code></pre>
  
  <p>The only solution that was close to working as intended, was to install docker directly on Jenkins container and then setting user for jenkins. It works, but only until docker image is running. When I kill it and run it again, docker isn't installed on container and so every pipeline fails again. I can't have that, I cannot have a downtime caused by say remote server being down. I'd have to manually install docker on that Jenkins container every time something was down.</p>
  
  <p>Any ideas?</p>
  
Tags: <docker><jenkins><continuous-integration>
Title: Maintaining Jenkins configuration with docker
UserDisplayName: Lovs
ThreadText: # Maintaining Jenkins configuration with docker
  
  (Asked by: username_0 on 2019-02-15)
  
  I'm trying to configure CI with Jenkins for my private project. Problem:
  
  * whenever I start building a pipeline project, it gives me ,,Docker is not found'' error
  * whenever I try to work around this by installing npm plugin and running bash script `npm install` as a build step, I get node/npm not found
  
  Solutions I've found and tried:
  
  According to official Jenkins docker image docs, all one is supposed to do is to mount docker.socket in dockerfile/docker-compose file and it should ,,just'' work (it doesn't) - example:
  
  ```
  volumes:
       - /var/run/docker.sock:/var/run/docker.sock
  
  ```
  
  The only solution that was close to working as intended, was to install docker directly on Jenkins container and then setting user for jenkins. It works, but only until docker image is running. When I kill it and run it again, docker isn't installed on container and so every pipeline fails again. I can't have that, I cannot have a downtime caused by say remote server being down. I'd have to manually install docker on that Jenkins container every time something was down.
  
  Any ideas?
  
  **Tags:** docker, jenkins, continuous-integration
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-02-27. Score: 1
  
  1. There are two ways to run Jenkins builds.
     1. The build node executes the build. In that case, all tools the build needs have to be installed on that node/slave.
     2. The build is run inside a Docker container (with a build node as host). In that case, the Docker image for the build needs to contain all the tools the build needs, but the Jenkins node doesn't have to.
  2. "Kill and run again" as in `docker stop $name; docker rm $name; docker run ...`? Sure, that deletes all data local to that container.
  
     * If you want to stop and restart the same container, use `docker stop` and `docker start` instead.
     * If you want to carry data over from one container to another, use [volumes](https://docs.docker.com/storage/volumes/).
  3. If you want to go with 1.1 and you need all your Jenkins nodes to come equipped with a certain set of tools (such as Docker, npm, ...), create your own Docker image for them.
  
  
  ---
  
  