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 networking on windows IP confusion
  • Is docker swarm manager part of the swarm cluster?
  • How to access a container from a Bluemix app?
  • Error Accesing to container on Bluemix
  • GitLab CI runner - can't access other repository
  • How to change the resources allocated to a container at run time?
  • 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?

  • Docker Ubuntu with nginx, php-fpm and s3fs but s3fs does not work
  • Docker containers shut down after systemd start
  • Tomcat Docker Container: host webapp directory mounted as container webapp directory
  • Integrating Docker-Machine with Amazon EC2
  • JDBC driver class not loading for JAVA app when it connects to Postgres in Docker
  • How to execute scripts after docker-compose up?
  • 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.