title: How to run the liquibase docker image in Jenkins containerized docker environment
body: <p>I'm doing POC with liquibase docker image,</p>
  <p>I would like to run the <code>liquibase</code> docker image in docker with Jenkins kubernetes POD template. unfortunately unable to make it.</p>
  <p>And also I have attached the Jenkins file and my observation.</p>
  <p><strong>Jenkins File</strong></p>
  <pre><code>def workspace_dir = &quot;/home/jenkins/agent/workspace/${env.JOB_BASE_NAME}&quot;
  def project_name = &quot;master-chart&quot;
  def isDeployerJob = (env.JOB_BASE_NAME).contains(&quot;deploy&quot;) ? &quot;true&quot; : &quot;false&quot;
  
  // These variables come from the build parameters in the Jenkins job
  def git_branch = git_branch
  def release_version
  
  
  if (isDeployerJob == &quot;true&quot;) {
      // Extracting the release version from the branch
      def temp = git_branch.split(&quot;/&quot;)
      release_version = temp[temp.length - 1]
  
      switch(environment) {
        case &quot;dev&quot;:
          hs_jdbc_url=&quot;jdbc:postgresql://40.xx.xx.xx:5432/dbname&quot;
          db_username=&quot;username&quot;
          db_password=&quot;pwd&quot;
          break
        default:
          break
      }
  } 
  
  pipeline {
  
    agent {
      kubernetes {
        cloud 'eks-tools-13'
        yaml &quot;&quot;&quot;
  apiVersion: v1
  kind: Pod
  spec:
    containers:
    - name: azcli-kubectl-helm
      image: internal.docker.cioxhealth.com/azcli-kubectl-helm
      command:
        - cat
      tty: true
    - name: docker
      image: docker
      command:
        - cat
      tty: true
      privileged: true
      volumeMounts:
        - name: dockersock
          mountPath: /var/run/docker.sock
    volumes:
      - name: dockersock
        hostPath:
          path: /var/run/docker.sock
  &quot;&quot;&quot;
      }
    }
  
    stages {
          
      stage('Install Database Scripts') {
        when {
          expression {
            &quot;${isDeployerJob}&quot; == &quot;true&quot;
          }
        }
        steps {
          container('docker') { 
              sh &quot;&quot;&quot;
                 docker run --rm --network=&quot;host&quot; -v ${workspace_dir}/db:/liquibase/changelog liquibase/liquibase --url=${hs_jdbc_url} --changeLogFile=db.changelog-master.yaml --driver=org.postgresql.Driver --username=${db_username} --password=${db_password} --logLevel=info  update
              &quot;&quot;&quot;
          }
        }
      }   
    
    }
  }
  
  </code></pre>
  <p>For verifying the files, I have getting into running container</p>
  <p><strong>Jenkins Master Node:</strong>
  <code>ls -ltr /home/jenkins/agent/workspace/master-chart-deploy/db</code></p>
  <pre><code>total 4
  drwxr-xr-x    3 1000     1000            21 Nov  6 04:35 sql
  drwxr-xr-x    3 1000     1000            21 Nov  6 04:35 rollback
  drwxr-xr-x    4 1000     1000            35 Nov  6 04:35 migration
  -rw-r--r--    1 1000     1000           154 Nov  6 04:35 db-master-changelog.yaml
  drwxr-xr-x    2 1000     1000            38 Nov  6 04:35 changelog
  </code></pre>
  <p><strong>Docker container on master-chart-deploy-259-qxrn5-nqq7j-hhlb8</strong></p>
  <p><code>ls -ltr /home/jenkins/agent/workspace/master-chart-deploy/db</code></p>
  <pre><code>total 4
  drwxr-xr-x    3 1000     1000            21 Nov  6 04:35 sql
  drwxr-xr-x    3 1000     1000            21 Nov  6 04:35 rollback
  drwxr-xr-x    4 1000     1000            35 Nov  6 04:35 migration
  -rw-r--r--    1 1000     1000           154 Nov  6 04:35 db-master-changelog.yaml
  drwxr-xr-x    2 1000     1000            38 Nov  6 04:35 changelog
  </code></pre>
  <p><strong>Liquibase Container</strong></p>
  <pre><code>docker run --rm '--network=host' -v /home/jenkins/agent/workspace/master-chart-deploy/db:/liquibase/changelog liquibase/liquibase -- ls -ltr /liquibase/changelog
  </code></pre>
  <p>total 0</p>
  <p><strong>Files are not available in the <code>liquibase</code> running container.</strong> due this the following error has been occurred.</p>
  <p>Error:</p>
  <pre><code>Starting Liquibase at 14:50:38 (**version 4.1.1** #10 built at 2020-10-12 19:24+0000)
  [2020-11-05 14:50:38] INFO [liquibase.lockservice] Successfully acquired change log lock
  [2020-11-05 14:50:38] INFO [liquibase.lockservice] Successfully released change log lock
  Unexpected error running Liquibase: db-master-changelog.yaml does not exist
  For more information, please use the --logLevel flag
  [2020-11-05 14:50:38] SEVERE [liquibase.integration] Unexpected error running Liquibase: db-master-changelog.yaml does not exist
  liquibase.exception.ChangeLogParseException: db-master-changelog.yaml does not exist
      at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:27)
      at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:337)
      at liquibase.Liquibase.lambda$update$1(Liquibase.java:229)
      at liquibase.Scope.lambda$child$0(Scope.java:160)
      at liquibase.Scope.child(Scope.java:169)
      at liquibase.Scope.child(Scope.java:159)
      at liquibase.Scope.child(Scope.java:138)
      at liquibase.Liquibase.runInScope(Liquibase.java:2277)
      at liquibase.Liquibase.update(Liquibase.java:215)
      at liquibase.Liquibase.update(Liquibase.java:201)
      at liquibase.integration.commandline.Main.doMigration(Main.java:1760)
      at liquibase.integration.commandline.Main$1.lambda$run$0(Main.java:361)
      at liquibase.Scope.lambda$child$0(Scope.java:160)
  </code></pre>
  <ul>
  <li>May I know, What did I do wrong in this case? and why files are not available in <code>liquibase</code> running container?</li>
  <li>Is this a problem, because of file permissions due to Docker in Docker case?</li>
  <li>Is there any other way I can achieve this?</li>
  </ul>
  <p>Thank you in advance for the help.</p>