Sonar-scanner-cli docker container help

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Docker sonar-scanner-cli:latest

  • what are you trying to achieve
    Scanning python code in docker container and then pushing results back to sonar server.

  • what have you tried so far to achieve this
    I have been playing with the docker run commands for the last few hours and using various runtime args to try and have the scan happen and then push the results to the server.

  • My question

So I have been reading the documentation and it touches very lightly on how to use sonar-scanner the docker container but then I cant find any more information on how to pass the arguments that contain the into the run args or how to pass the file into the docker image run.

I completely admit im sure this is somewhere in the documentation and im just blind and cant find it but is there somewhere that provides a clear example or tutorial on using the sonar-scanner for python, html5 & js code inside a docker container because im not having any luck finding it or getting it to work on my own sorry?

Any assistance with this would be really appreciated.

Hi James, welcome to the SonarSource Community!

You might have missed the section where it’s covered in our docs.

The key part there which answers your question is the bind mount

-v "${YOUR_REPO}:/usr/src"

Where the directory containing your project should be substituted for the ${YOUR_REPO} part. If a is included in the root of the project, it will then be picked up.

Hi there Jeff thanks for the response.

I did read this in the Docs earlier and maybe this is my misunderstanding so if i’m sitting in the root level of my app where the is and I use the docker run command that is in the documentation there what am I mean to put into the ${your_repo) variable if the docker run command is being issued from the app root directory.

Would I be inserting “.” to direct the container to pick up everything in the current directory or do I need to copy the code into a docker volume and then ${your_repo} is then the link to my docker volume containing the code?

Just “.” in that case is what I’d try. The point is to bind to an existing directory, not require you to copy or manually manage anything.

Right ok, yea im not having any luck with the “.” I was just hoping to not have to create binds and volumes every time but thats ok.

Thank you very much for the help I appreciate the advice and direction :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.