Answers: <p>According the the Jenkins docs, you could use your custom docker image as the <a href="https://jenkins.io/doc/book/pipeline/docker/#execution-environment" rel="nofollow noreferrer">execution environment</a>, assuming the server Jenkins is running on has Docker installed/running. </p>
  
  <pre><code>pipeline {
      agent {
          docker { image 'your-custom-image' }
      }
      stages {
          stage('Build') {
              steps {
                  sh 'commands to run in your docker image here'
              }
          }
      }
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-12-20T20:43:43.370Z
Answers: ah nice, I can even do "agent { dockerfile true }" and get the Dockerfile from the repo. Only downside is that this plugin uses the commandline docker client instead of the API.
Answers: Simon Richter
Answers: CC BY-SA 4.0
Answers: 2019-12-20T20:15:06.463Z
Answers: 2019-12-20T20:15:06.463Z
Answers: Argyle
Body: <p>I have a working Dockerfile that creates a build environment for a legacy app, and now I'd like to use that environment from Jenkins, ideally allowing for incremental builds.</p>
  
  <p>The environment is too old to run a recent version of Java, which means it cannot be used as an agent directly.</p>
  
  <p>Is there a way to run a series of build steps inside a container without the container itself running an agent?</p>
  
Tags: <docker><jenkins>
Title: Legacy build environment in Docker container, incompatible with Jenkins agent
UserDisplayName: Simon Richter
ThreadText: # Legacy build environment in Docker container, incompatible with Jenkins agent
  
  (Asked by: username_0 on 2019-12-16)
  
  I have a working Dockerfile that creates a build environment for a legacy app, and now I'd like to use that environment from Jenkins, ideally allowing for incremental builds.
  
  The environment is too old to run a recent version of Java, which means it cannot be used as an agent directly.
  
  Is there a way to run a series of build steps inside a container without the container itself running an agent?
  
  **Tags:** docker, jenkins
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-12-20. Score: 1 | Accepted answer
  
  According the the Jenkins docs, you could use your custom docker image as the [execution environment](https://jenkins.io/doc/book/pipeline/docker/#execution-environment), assuming the server Jenkins is running on has Docker installed/running.
  
  ```
  pipeline {
      agent {
          docker { image 'your-custom-image' }
      }
      stages {
          stage('Build') {
              steps {
                  sh 'commands to run in your docker image here'
              }
          }
      }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: ah nice, I can even do "agent { dockerfile true }" and get the Dockerfile from the repo. Only downside is that this plugin uses the commandline docker client instead of the API.  
  
  ---
  
  