When using docker.inside(){....} jenkins does not clean up volume mounts. This fills the filesystem and can lead to failure of future builds due to space and/or handle exhaustion.

      Output from a jenkins job shows that the 'docker rm' command is missing the '-v' to clean up created volumes.

      pipeline:

          docker.image('imagename').inside {
            stage('NPM Install') {
                withEnv(["NPM_CONFIG_LOGLEVEL=warn"]) {
                    sh 'npm install'
                }
              ... more stages...
            }
      

      output (shortened)

      [Pipeline] withDockerContainer
      $ docker run -t -d -u 501:65533 -w /var/jenkins_home/workspace/ker-jenkins_docker-delivery-XF3HYD5LNFF76MFG42DBYCT2GOEYPA563ZLXEPKNRCN35YXLGQPQ --volumes-from 1f171ac72b1c5e51759b2cde36d9360965ccf21a4fc64a52e107908371621b64 -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat <imagename>
      [Pipeline] {
      
      ....
      
      $ docker stop --time=1 b3c49f9e48e81c6955520fe8b7ab540990198c11e29491094764f18de0043f43
      $ docker rm -f b3c49f9e48e81c6955520fe8b7ab540990198c11e29491094764f18de0043f43
      [Pipeline] // withDockerContainer
      

          [JENKINS-46006] image.inside leaks volumes

          Julien Leroy added a comment -

           I'm actually having the same issue. I use a container for test database (so it's forgotten after usage), and so I would like the volume to be deleted when the container is removed.

          Julien Leroy added a comment -  I'm actually having the same issue. I use a container for test database (so it's forgotten after usage), and so I would like the volume to be deleted when the container is removed.

          James Howe added a comment - - edited

          Same thing when using declarative docker agents.

          agent { docker { image 'node:14-alpine' } }
          stage('NPM Install') {
              environment { NPM_CONFIG_LOGLEVEL = 'warn' }
              steps { sh 'npm install' }
          }
          

          James Howe added a comment - - edited Same thing when using declarative docker agents. agent { docker { image 'node:14-alpine' } } stage( 'NPM Install' ) { environment { NPM_CONFIG_LOGLEVEL = 'warn' } steps { sh 'npm install' } }

          James Howe added a comment -

          jglick is this the right component for the current pipeline system? This issue has been unassigned for years.

          James Howe added a comment - jglick is this the right component for the current pipeline system? This issue has been unassigned for years.

          Jesse Glick added a comment -

          jameshowe the component is correct, but this plugin is basically unmaintained. My standing advice is to ignore it and use docker CLI commands directly.

          Jesse Glick added a comment - jameshowe the component is correct, but this plugin is basically unmaintained. My standing advice is to ignore it and use docker CLI commands directly.

          James Howe added a comment -

          Oh. Seems like a pretty central plugin to be unmaintained.

          It's also doesn't have the "up for adoption" warning.

          James Howe added a comment - Oh. Seems like a pretty central plugin to be unmaintained. It's also doesn't have the "up for adoption" warning.

            Unassigned Unassigned
            everflux Thomas Kruse
            Votes:
            6 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: