Answers: <p>Your <code>docker-agent is offline</code> because there are two parts to setting up an agent in Jenkins.</p>
  <ol>
  <li>Add a New Node in Jenkins side</li>
  <li>Setup at the agent side
  <a href="https://i.sstatic.net/9nS27PuK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9nS27PuK.png" alt="List item" /></a></li>
  </ol>
  <p>At the moment, Jenkins Docker Pipeline plugin on the Windows host can't execute Linux Docker images due to a bug <a href="https://issues.jenkins.io/browse/JENKINS-60473" rel="nofollow noreferrer">Docker pipeline: 'absolute path' error when running linux container under windows host</a>.</p>
  <p>Your options would be:</p>
  <ol>
  <li>Setup a Linux agent with docker installed.</li>
  <li>Although not recommended, if you cannot use a Linux agent, then setup up Jenkins using docker on a windows machine as mentioned in the documentation <a href="https://www.jenkins.io/doc/book/installing/docker/" rel="nofollow noreferrer">Setup Jenkins using Docker</a>. Use your master as a build agent for all docker related builds.</li>
  </ol>
  
Answers: CC BY-SA 4.0
Answers: 2024-12-22T11:10:39.863Z
Answers: 2024-12-22T11:10:39.863Z
Answers: Wanmi Siangshai
Body: <p>I am using Windows 11 and have installed the following software on my system:</p>
  <ul>
  <li>Jenkins: Version 2.479.2</li>
  <li>Docker Desktop: Version 4.36.0 (175267)</li>
  <li>Oracle 19c</li>
  </ul>
  <p><strong>Note</strong>: My Jenkins and Docker Desktop are running properly on my Windows system.</p>
  <p>I recently learned that it's possible to create a Docker agent and run Liquibase directly using Docker without needing to install it on my system. I want to implement this setup by configuring a Docker agent and using it as an agent in my Jenkins pipeline script.</p>
  <p>I installed plugins for Docker on my Jenkins which is running on local Windows:</p>
  <p><a href="https://i.sstatic.net/EDYbhweZ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EDYbhweZ.jpg" alt="Docker Plugin" /></a></p>
  <p>I have been trying to configure a Docker agent for Jenkins to use Liquibase, but I'm confused by the various resources and YouTube videos. Different suggestions seem to contradict one another, and none have worked for me so far.</p>
  <p>Here's a summary of the different approaches I came across:</p>
  <ol>
  <li><p>Configuring in Jenkins (Declarative Pipeline settings):</p>
  <ul>
  <li><p>Navigate to Manage Jenkins -&gt; System -&gt; Docker Declarative Pipeline.</p>
  </li>
  <li><p>Enter the Docker Label and Docker Registry URL</p>
  <p><a href="https://i.sstatic.net/199rnIa3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/199rnIa3.png" alt="Declarative Pipeline" /></a></p>
  </li>
  </ul>
  </li>
  <li><p>Configuring Docker in Jenkins Tools settings:</p>
  <ul>
  <li><p>Go to Manage Jenkins -&gt; Tools -&gt; Docker Installations.</p>
  </li>
  <li><p>Add a Docker configuration with details like:</p>
  <ul>
  <li>Docker Name</li>
  <li>Installation Root</li>
  </ul>
  <p><a href="https://i.sstatic.net/wi4ntIpY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wi4ntIpY.png" alt="Docker Tools setting" /></a></p>
  </li>
  </ul>
  </li>
  <li><p>Creating a new agent node:</p>
  <ul>
  <li>Navigate to Manage Jenkins -&gt; Nodes -&gt; New Node -&gt; Cloud.</li>
  <li>Set up the node to act as a Docker agent.</li>
  </ul>
  <p><a href="https://i.sstatic.net/9MdrskKN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9MdrskKN.png" alt="New Node agent creation step - 1" /></a></p>
  <p><a href="https://i.sstatic.net/CmzxWyrk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CmzxWyrk.png" alt="New Node agent creation step - 2" /></a></p>
  <p><a href="https://i.sstatic.net/rVf02kZ1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rVf02kZ1.png" alt="New Node agent creation step - 3" /></a></p>
  <p><a href="https://i.sstatic.net/fUbrKu6t.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fUbrKu6t.png" alt="New Node agent creation step - 4" /></a></p>
  <p><a href="https://i.sstatic.net/5NrhCgHO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5NrhCgHO.png" alt="New Node agent creation step - 5" /></a></p>
  </li>
  <li><p>Creating a Docker template in Cloud:</p>
  <ul>
  <li>Use a Docker template to define the agent environment.</li>
  </ul>
  <p><a href="https://i.sstatic.net/lQNqXO9F.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lQNqXO9F.png" alt="Docker cloud step 1 " /></a></p>
  <p><a href="https://i.sstatic.net/HlrCCWSO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HlrCCWSO.png" alt="Docker cloud step 2 " /></a></p>
  <p><a href="https://i.sstatic.net/JfXou312.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JfXou312.png" alt="Docker cloud step 3 " /></a></p>
  <p><a href="https://i.sstatic.net/oJ229FTA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oJ229FTA.png" alt="Docker cloud step 4 " /></a></p>
  <p><a href="https://i.sstatic.net/npJi5ePN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/npJi5ePN.png" alt="Docker cloud step 5 " /></a></p>
  <p><a href="https://i.sstatic.net/xzKIOviI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xzKIOviI.png" alt="Docker cloud step 6 " /></a></p>
  <p>For template creation, no changes have been made to the remaining properties.</p>
  </li>
  <li><p>Adjusting Docker Desktop settings:</p>
  <ul>
  <li>Go to Docker Desktop -&gt; Settings -&gt; General.</li>
  <li>Check the option: Expose daemon on tcp://localhost:2375 without TLS.</li>
  </ul>
  <p><a href="https://i.sstatic.net/cw7Ul5tg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/cw7Ul5tg.png" alt="Docker for Desktop " /></a></p>
  </li>
  <li><p>Specifying Docker engine settings:</p>
  <ul>
  <li>Some resources suggested using npipe://./pipe/docker_engine for Windows systems.</li>
  <li>Others recommended using TCP: tcp://localhost:2375.</li>
  </ul>
  <p><a href="https://i.sstatic.net/3kyqR6lD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3kyqR6lD.png" alt="Docker engine " /></a></p>
  </li>
  </ol>
  <p>My pipeline script:</p>
  <pre class="lang-none prettyprint-override"><code>pipeline {
      agent {
          docker {
              image 'liquibase/liquibase:latest'  
              label 'docker-agent'          
          }
      }
      
      stages {
          stage('Check Liquibase Version') {
              steps {
                  bat &quot;liquibase --version&quot;  
              }
          }
      }
  }
  </code></pre>
  <p>Pipeline script does not run, it shows docker-agent is offline:</p>
  <p><a href="https://i.sstatic.net/nSdgsUNP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nSdgsUNP.png" alt="Jenkin running ..." /></a></p>
  
Tags: <docker><jenkins-pipeline><cicd><build-pipeline>
Title: How to run Liquibase Docker in Jenkins as Docker agent
UserDisplayName: codeholic24
ThreadText: # How to run Liquibase Docker in Jenkins as Docker agent
  
  (Asked by: username_0 on 2024-12-12)
  
  I am using Windows 11 and have installed the following software on my system:
  
  * Jenkins: Version 2.479.2
  * Docker Desktop: Version 4.36.0 (175267)
  * Oracle 19c
  
  **Note**: My Jenkins and Docker Desktop are running properly on my Windows system.
  
  I recently learned that it's possible to create a Docker agent and run Liquibase directly using Docker without needing to install it on my system. I want to implement this setup by configuring a Docker agent and using it as an agent in my Jenkins pipeline script.
  
  I installed plugins for Docker on my Jenkins which is running on local Windows:
  
  [![Docker Plugin](https://i.sstatic.net/EDYbhweZ.jpg)](https://i.sstatic.net/EDYbhweZ.jpg)
  
  I have been trying to configure a Docker agent for Jenkins to use Liquibase, but I'm confused by the various resources and YouTube videos. Different suggestions seem to contradict one another, and none have worked for me so far.
  
  Here's a summary of the different approaches I came across:
  
  1. Configuring in Jenkins (Declarative Pipeline settings):
  
     * Navigate to Manage Jenkins -> System -> Docker Declarative Pipeline.
     * Enter the Docker Label and Docker Registry URL
  
       [![Declarative Pipeline](https://i.sstatic.net/199rnIa3.png)](https://i.sstatic.net/199rnIa3.png)
  2. Configuring Docker in Jenkins Tools settings:
  
     * Go to Manage Jenkins -> Tools -> Docker Installations.
     * Add a Docker configuration with details like:
  
       + Docker Name
       + Installation Root
  
       [![Docker Tools setting](https://i.sstatic.net/wi4ntIpY.png)](https://i.sstatic.net/wi4ntIpY.png)
  3. Creating a new agent node:
  
     * Navigate to Manage Jenkins -> Nodes -> New Node -> Cloud.
     * Set up the node to act as a Docker agent.
  
     [![New Node agent creation step - 1](https://i.sstatic.net/9MdrskKN.png)](https://i.sstatic.net/9MdrskKN.png)
  
     [![New Node agent creation step - 2](https://i.sstatic.net/CmzxWyrk.png)](https://i.sstatic.net/CmzxWyrk.png)
  
     [![New Node agent creation step - 3](https://i.sstatic.net/rVf02kZ1.png)](https://i.sstatic.net/rVf02kZ1.png)
  
     [![New Node agent creation step - 4](https://i.sstatic.net/fUbrKu6t.png)](https://i.sstatic.net/fUbrKu6t.png)
  
     [![New Node agent creation step - 5](https://i.sstatic.net/5NrhCgHO.png)](https://i.sstatic.net/5NrhCgHO.png)
  4. Creating a Docker template in Cloud:
  
     * Use a Docker template to define the agent environment.
  
     [![Docker cloud step 1 ](https://i.sstatic.net/lQNqXO9F.png)](https://i.sstatic.net/lQNqXO9F.png)
  
     [![Docker cloud step 2 ](https://i.sstatic.net/HlrCCWSO.png)](https://i.sstatic.net/HlrCCWSO.png)
  
     [![Docker cloud step 3 ](https://i.sstatic.net/JfXou312.png)](https://i.sstatic.net/JfXou312.png)
  
     [![Docker cloud step 4 ](https://i.sstatic.net/oJ229FTA.png)](https://i.sstatic.net/oJ229FTA.png)
  
     [![Docker cloud step 5 ](https://i.sstatic.net/npJi5ePN.png)](https://i.sstatic.net/npJi5ePN.png)
  
     [![Docker cloud step 6 ](https://i.sstatic.net/xzKIOviI.png)](https://i.sstatic.net/xzKIOviI.png)
  
     For template creation, no changes have been made to the remaining properties.
  5. Adjusting Docker Desktop settings:
  
     * Go to Docker Desktop -> Settings -> General.
     * Check the option: Expose daemon on tcp://localhost:2375 without TLS.
  
     [![Docker for Desktop ](https://i.sstatic.net/cw7Ul5tg.png)](https://i.sstatic.net/cw7Ul5tg.png)
  6. Specifying Docker engine settings:
  
     * Some resources suggested using npipe://./pipe/docker\_engine for Windows systems.
     * Others recommended using TCP: tcp://localhost:2375.
  
     [![Docker engine ](https://i.sstatic.net/3kyqR6lD.png)](https://i.sstatic.net/3kyqR6lD.png)
  
  My pipeline script:
  
  ```none
  pipeline {
      agent {
          docker {
              image 'liquibase/liquibase:latest'  
              label 'docker-agent'          
          }
      }
      
      stages {
          stage('Check Liquibase Version') {
              steps {
                  bat "liquibase --version"  
              }
          }
      }
  }
  
  ```
  
  Pipeline script does not run, it shows docker-agent is offline:
  
  [![Jenkin running ...](https://i.sstatic.net/nSdgsUNP.png)](https://i.sstatic.net/nSdgsUNP.png)
  
  **Tags:** docker, jenkins-pipeline, cicd, build-pipeline
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-12-22. Score: 0
  
  Your `docker-agent is offline` because there are two parts to setting up an agent in Jenkins.
  
  1. Add a New Node in Jenkins side
  2. Setup at the agent side
     [![List item](https://i.sstatic.net/9nS27PuK.png)](https://i.sstatic.net/9nS27PuK.png)
  
  At the moment, Jenkins Docker Pipeline plugin on the Windows host can't execute Linux Docker images due to a bug [Docker pipeline: 'absolute path' error when running linux container under windows host](https://issues.jenkins.io/browse/JENKINS-60473).
  
  Your options would be:
  
  1. Setup a Linux agent with docker installed.
  2. Although not recommended, if you cannot use a Linux agent, then setup up Jenkins using docker on a windows machine as mentioned in the documentation [Setup Jenkins using Docker](https://www.jenkins.io/doc/book/installing/docker/). Use your master as a build agent for all docker related builds.
  
  
  ---
  
  