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

  • How can I get an upstart script to properly manage running a docker image?
  • Django unable to connect to database.
  • Warning message of deprecated link option of Docker
  • docker: make BIND_DIR=. shell doesn't work
  • How to re-bind docker volume after removing data-only container?
  • Sharing precompiled assets across docker containers
  • 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 docker container can get IP where docker swarm runs
  • Docker for traditional web application with load balancing?
  • How can I change docker image configurations?
  • What's the difference between “docker stop” and “docker rm”?
  • Forwarding docker GELF logs to Logstash with Filebeat (or alternative?)
  • Git not found when running docker-machine create
  • 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.