Manually installing SonarQube plugins on Docker image

I want to create my custom SonarQube docker image, with some plugins already installed, but every time I run my container, the plugins are not there. It’s like something removes the plugins from /opt/sonarqube/extensions/plugins and copy the bundled-plugins there.

My Dockerfile

  • Docker Container: time/timezone wrong
  • Docker image error: “/bin/sh: 1: [python,: not found”
  • How to use Docker's COPY/ADD instructions to copy a single file to an image
  • Not able to push docker images to docker private registry
  • Storage requirement when using for AWS ECS
  • Bluemix Docker container cf ic run doesn't seem to accept -p sub-command
  • FROM sonarqube
    
    ENV SONARQUBE_HOME /opt/sonarqube
    
    RUN wget "http://downloads.sonarsource.com/plugins/org/codehaus/sonar-plugins/sonar-scm-git-plugin/1.1/sonar-scm-git-plugin-1.1.jar" \
        && wget "https://github.com/SonarSource/sonar-java/releases/download/3.12-RC2/sonar-java-plugin-3.12-build4634.jar" \
        && wget "https://github.com/SonarSource/sonar-github/releases/download/1.1-M9/sonar-github-plugin-1.1-SNAPSHOT.jar" \
        && wget "https://github.com/SonarSource/sonar-auth-github/releases/download/1.0-RC1/sonar-auth-github-plugin-1.0-SNAPSHOT.jar" \
        && wget "https://github.com/QualInsight/qualinsight-plugins-sonarqube-badges/releases/download/qualinsight-plugins-sonarqube-badges-1.2.1/qualinsight-sonarqube-badges-1.2.1.jar" \
        && mv *.jar $SONARQUBE_HOME/extensions/plugins \
        && ls -lah $SONARQUBE_HOME/extensions/plugins
    

    I tried listing the folder, and it lists my desired plugins. But if I list the same folder after I started the container, they are gone.

    I’ve also tried removing the bundled-plugins with no luck.

    Any ideas?

  • How can I debug my docker container with phpStorm
  • Create Docker container with Nodev4.4.7 and Python3
  • Missing tag after docker stack deploy
  • How to Copy Files From Docker Ubuntu Container to Windows Host
  • Why does docker build not use the build cache?
  • Docker return codes from background commands
  • 3 Solutions collect form web for “Manually installing SonarQube plugins on Docker image”

    The Sonarqube image uses a volume for the /extensions/ directory, which results in the files in that directory not being stored in the image’s filesystem; see the Dockerfile

    To package those extensions in your image, you need them outside of that directory, and copy those files to the /extensions/ in an entrypoint script, or store your plugins in a separate image, and mount those plugins as a volume when running the image; you can find an example doing that here; https://github.com/SonarSource/docker-sonarqube/blob/master/recipes.md

    Note the accepted answer is no longer true. It should work if you directly use recent parent sonarqube image. So if the Dockerfile metioned in the question does not work, you have a different problem.

    See commit 80366e3419d698b4bba4447f153418ef64b3b705 for more info.

    Remove volume for “conf”, “logs” and “extensions” directories
    Explicit declaration of volume is appropriate only for data stored by
    application, volume for configurable things is almost never
    appropriate (see docker-library/official-images#2437).

    This reverts commit 69fca2e. And additionally removes declaration of
    volume for “extensions” directory.

    Before SonarQube 5.6, plugins are stored in a volume, so the appropriate command is (after starting the sonarqube container):

    wget https://sonarsource.bintray.com/Distribution/sonar-auth-github-plugin/sonar-auth-github-plugin-1.2.jar -P `docker inspect -f '{{ (index .Mounts 1).Source }}' sonarqube`/plugins
    docker restart sonarqube
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.