Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51410

Error stopping mongod service inside Docker container

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker-workflow-plugin
    • Jenkins 2.107.3
      Amazon Linux 4.14.33-51.37.amzn1.x86_64
      Docker version 17.12.1-ce, build 3dfb8343b139d6342acfd9975d7f1068b5b1c3d3
      Java OpenJDK version 1.8.0_171
      Jenkins installed via YUM, builds run on slaves connected via SSH

      I have a Docker image with MongoDB installed. My pipeline tries to start the mongod service, run some database commands, and then stop the mongod service. When trying to stop the mongod service, the pipeline hangs for 5 minutes and then returns a failed exit status.

      I've confirmed that I'm able to run these same commands within a Docker container manually, on the same machine, with no issues, so this seems like a Jenkins issue of some sort.

      To reproduce:

      Create an image using the following Dockerfile:

      FROM amazonlinux
      
      ENV MONGO_VERSION=3.6
      
      RUN echo -e "[mongodb-org-${MONGO_VERSION}]\nname=MongoDB\nbaseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/${MONGO_VERSION}/x86_64/\nenabled=1\ngpgcheck=1\ngpgkey=https://www.mongodb.org/static/pgp/server-${MONGO_VERSION}.asc\n" > /etc/yum.repos.d/mongodb.repo \
      && yum groupinstall -y "Development Tools" \
      && yum install -y mongodb-org
      
      CMD ["/bin/bash"]
      

      Run the following pipeline on a Jenkins slave running Amazon Linux:

      pipeline {
        agent {
          docker {
            image 'your-mongo-image'
            args '-u root'
          }
        }
        stages {
          stage('Test') {
            steps {
              sh 'service mongod start'
              sh 'service mongod stop' // This is the step that hangs for 5 minutes before returning a non-zero exit status
            }
          }
        }
      }

       

            Unassigned Unassigned
            areifert Alexander Reifert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: