{"componentChunkName":"component---src-templates-tags-js","path":"/tags/docker/","result":{"data":{"allMarkdownRemark":{"totalCount":2,"edges":[{"node":{"id":"38f38c9e-3667-53ff-ab7d-4c474b19875c","html":"<p>I help some of my friends perform code reviews on their code bases from time to time as a side activity. I’ve used <a href=\"https://www.npmjs.com/package/codelyzer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"language-text\">codelyzer</code></a> before and it’s very similar to <code class=\"language-text\">tslint</code> in a sense. However, I wanted to test something new and thought let’s give <a href=\"https://www.sonarqube.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">SonarQube</a> a shot this time.</p>\n<!--more-->\n<h2 id=\"intro\" style=\"position:relative;\"><a href=\"#intro\" aria-label=\"intro permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intro</h2>\n<p><a href=\"https://www.sonarqube.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">SonarQube</a>® is an automatic code review tool to detect bugs, vulnerabilities and code smells in your code. It can integrate with your existing workflow to enable continuous code inspection across your project branches and pull requests.</p>\n<p>It has a server component where you can create projects and apply configurations like adding plugins and updating existing ones. And then there is a scanner component where it scans your code base and sends the result to the server to show in the <em>SonarQube</em> dashboard.</p>\n<p>There are multiple versions of <em>SonarQube</em> but we’re going to use the <a href=\"https://www.sonarqube.org/community/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">community edition</a> which is free and open source.</p>\n<p>So without further ado, let’s get to it.</p>\n<h2 id=\"setup\" style=\"position:relative;\"><a href=\"#setup\" aria-label=\"setup permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setup</h2>\n<p><a href=\"https://docs.sonarqube.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">The documentation</a> is really great, and there is a great <a href=\"https://docs.sonarqube.org/latest/setup/overview/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">two minute get started</a> which is what I used to get my hand wet real quick. However, soon I realised that I have to install a lot of dependencies to get it working.</p>\n<p>I was thinking how to avoid the extra installations, when suddenly a smile came to my face when I saw there is a docker image as well.</p>\n<p>On the <a href=\"https://hub.docker.com/_/sonarqube/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Docker Hub</a>, you can find the information you need to get started, but for the purpose of this article, I just use a single command to get it going.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"98914208732539680000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`docker run -d --name sonarqube -p 9000:9000 sonarqube`, `98914208732539680000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">docker</span> run <span class=\"token parameter variable\">-d</span> <span class=\"token parameter variable\">--name</span> sonarqube <span class=\"token parameter variable\">-p</span> <span class=\"token number\">9000</span>:9000 sonarqube</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>This command will pull the image down and create a container from it. Run the container in the background mode and then exposes the port 9000 through to host.</p>\n<p>Once done, you need to wait for a few mistunes for the server to get started. You can open a browser of your choice and go to <code class=\"language-text\">localhost:9000</code> to see the server dashboard.</p>\n<p>Use the default username as <code class=\"language-text\">admin</code> and the password <code class=\"language-text\">admin</code> to login.</p>\n<p><img src=\"/9572ec987eacfab62a0913acfc3f9a05/sonarhome.jpg\" alt=\"SonarQube home page\"></p>\n<h2 id=\"create-a-project\" style=\"position:relative;\"><a href=\"#create-a-project\" aria-label=\"create a project permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create a project</h2>\n<p>I don’t want to go deep into <em>SonarQube</em> here, but a project represents a code base where you can see the result of a scan done by the scanner. So once logged in, click on create a new project button in the centre of the page, then enter a unique project key and a display name.</p>\n<p>On the next page enter a name for your project token. This is the key which scanner will use to authenticate to the server and send the result of a scan up.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 502px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/06fd8f70fa3859909660ea319638ea41/6f76c/newproj.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 69.25925925925927%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAOABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3aoUf//EABYQAQEBAAAAAAAAAAAAAAAAABABEf/aAAgBAQABBQLGP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABkQAAIDAQAAAAAAAAAAAAAAAAERACAxUf/aAAgBAQABPyFOQIYKv//aAAwDAQACAAMAAAAQUA//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAbEAEAAgIDAAAAAAAAAAAAAAABABEQcUFhkf/aAAgBAQABPxA5Q6GAaQNS9+SjaFV1n//Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"New Project screen\"\n        title=\"\"\n        src=\"/static/06fd8f70fa3859909660ea319638ea41/6f76c/newproj.jpg\"\n        srcset=\"/static/06fd8f70fa3859909660ea319638ea41/6f81f/newproj.jpg 270w,\n/static/06fd8f70fa3859909660ea319638ea41/6f76c/newproj.jpg 502w\"\n        sizes=\"(max-width: 502px) 100vw, 502px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Take note of this key as you can never see it once you’re navigated away from this page. Click continue and you’ll see a screen where you can specify your project configuration.</p>\n<p>I wanted to run this on an Angular project with TypeScript, so I chose other, and then windows from the OS prompt.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 605px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/86a93b55b1d4586818b60c320e2b8049/3cb18/projectconfig.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 63.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHtN1KF/8QAGBAAAgMAAAAAAAAAAAAAAAAAAAERICL/2gAIAQEAAQUCbg3X/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFxAAAwEAAAAAAAAAAAAAAAAAABEgQv/aAAgBAQAGPwJGZ//EABsQAAEFAQEAAAAAAAAAAAAAAAEAEBEhMWGR/9oACAEBAAE/IQFaCcpZ3wWFkqOt/9oADAMBAAIAAwAAABCfz//EABURAQEAAAAAAAAAAAAAAAAAABEQ/9oACAEDAQE/EBn/xAAVEQEBAAAAAAAAAAAAAAAAAAAQEf/aAAgBAgEBPxCn/8QAGRABAAMBAQAAAAAAAAAAAAAAAQARMWEh/9oACAEBAAE/EBpOIquQMuMDPZYVpUEOoT//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"project config screen\"\n        title=\"\"\n        src=\"/static/86a93b55b1d4586818b60c320e2b8049/3cb18/projectconfig.jpg\"\n        srcset=\"/static/86a93b55b1d4586818b60c320e2b8049/6f81f/projectconfig.jpg 270w,\n/static/86a93b55b1d4586818b60c320e2b8049/09d21/projectconfig.jpg 540w,\n/static/86a93b55b1d4586818b60c320e2b8049/3cb18/projectconfig.jpg 605w\"\n        sizes=\"(max-width: 605px) 100vw, 605px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"downloading-the-scanner\" style=\"position:relative;\"><a href=\"#downloading-the-scanner\" aria-label=\"downloading the scanner permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Downloading the scanner</h2>\n<p>At this point you need to download the scanner and unzip it in a folder named <code class=\"language-text\">sonarqube</code> on your drive. I usually use <code class=\"language-text\">c:\\tools</code> for these sort of usage (replace this with what you used if you chose to unzip it elsewhere).</p>\n<p>Once done, open your scanner config file named <code class=\"language-text\">sonar-scanner.properties</code> from <code class=\"language-text\">c:\\tools\\sonarqube\\config</code> folder and uncomment the line which specifies the server address.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"48353007543368930000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`#Configure here general information about the environment, such as SonarQube server connection details for example\r\n#No information about specific project should appear here\r\n\r\n#----- Default SonarQube server\r\nsonar.host.url=http://localhost:9000\r\n\r\n#----- Default source code encoding\r\nsonar.sourceEncoding=UTF-8`, `48353007543368930000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-yaml line-numbers\"><code class=\"language-yaml\"><span class=\"token comment\">#Configure here general information about the environment, such as SonarQube server connection details for example</span>\r\n<span class=\"token comment\">#No information about specific project should appear here</span>\r\n\r\n<span class=\"token comment\">#----- Default SonarQube server</span>\r\nsonar.host.url=http<span class=\"token punctuation\">:</span>//localhost<span class=\"token punctuation\">:</span><span class=\"token number\">9000</span>\r\n\r\n<span class=\"token comment\">#----- Default source code encoding</span>\r\nsonar.sourceEncoding=UTF<span class=\"token punctuation\">-</span><span class=\"token number\">8</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"running-a-scan\" style=\"position:relative;\"><a href=\"#running-a-scan\" aria-label=\"running a scan permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Running a scan</h2>\n<p>Once done, you’re ready to go. Run the command below from your project root and wait for the scan to finish.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"17080815755364243000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`C:\\tools\\sonar\\bin\\sonar-scanner.bat -D&quot;sonar.projectKey=fp&quot; -D&quot;sonar.sources=.&quot; -D&quot;sonar.host.url=http://localhost:9000&quot; -D&quot;sonar.login=**********************************&quot; -D&quot;sonar.exclusions=node_modules/**/*&quot;`, `17080815755364243000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-powershell line-numbers\"><code class=\"language-powershell\">C:\\tools\\sonar\\bin\\sonar-scanner<span class=\"token punctuation\">.</span>bat <span class=\"token operator\">-</span>D<span class=\"token string\">\"sonar.projectKey=fp\"</span> <span class=\"token operator\">-</span>D<span class=\"token string\">\"sonar.sources=.\"</span> <span class=\"token operator\">-</span>D<span class=\"token string\">\"sonar.host.url=http://localhost:9000\"</span> <span class=\"token operator\">-</span>D<span class=\"token string\">\"sonar.login=**********************************\"</span> <span class=\"token operator\">-</span>D<span class=\"token string\">\"sonar.exclusions=node_modules/**/*\"</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Don’t forget to replace the key you got from the previous step in the <code class=\"language-text\">sonar.login</code> argument.</p>\n<blockquote>\n<p>💡 In the last step when you downloaded the scanner zip file, the command you need to execute is written down for you ready to go, just add the exclude folder to avoid code analysis on external libraries.</p>\n</blockquote>\n<p>It takes a while for the scan to finish based on the size of your code base. But once done, you can see the result in the <em>SonarQube</em> dashboard.</p>\n<blockquote>\n<p>ℹ️ Remember to run <code class=\"language-text\">npm install</code> or <code class=\"language-text\">yarn</code> if you’ve just forked the code base from your <code class=\"language-text\">git</code> repository. I faced a few errors before I realised I didn’t have those installed and they are used by the scanner.</p>\n</blockquote>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/29df73690949903c226b2735ef7d93db/9288f/scan.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 40.74074074074074%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAIF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAQD/2gAMAwEAAhADEAAAAciBJBf/xAAWEAADAAAAAAAAAAAAAAAAAAAAARD/2gAIAQEAAQUCHP/EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAABD/2gAIAQEABj8Cf//EABYQAAMAAAAAAAAAAAAAAAAAAAAQEf/aAAgBAQABPyFIf//aAAwDAQACAAMAAAAQ9D//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAZEAACAwEAAAAAAAAAAAAAAAAAAREhQVH/2gAIAQEAAT8QbqC2EuH/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"scan in progress\"\n        title=\"\"\n        src=\"/static/29df73690949903c226b2735ef7d93db/47311/scan.jpg\"\n        srcset=\"/static/29df73690949903c226b2735ef7d93db/6f81f/scan.jpg 270w,\n/static/29df73690949903c226b2735ef7d93db/09d21/scan.jpg 540w,\n/static/29df73690949903c226b2735ef7d93db/47311/scan.jpg 1080w,\n/static/29df73690949903c226b2735ef7d93db/0047d/scan.jpg 1620w,\n/static/29df73690949903c226b2735ef7d93db/274e1/scan.jpg 2160w,\n/static/29df73690949903c226b2735ef7d93db/9288f/scan.jpg 2626w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>And once done, here is yow your dashboard will look like. Obviously the code base I was reviewing was a bit chaotic.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 892px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/303844ddea00bcb177f38ea50a1773ee/65069/scanresult.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 83.7037037037037%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAARABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3aAAFB//xAAUEAEAAAAAAAAAAAAAAAAAAAAw/9oACAEBAAEFAh//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/AR//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/AR//xAAUEAEAAAAAAAAAAAAAAAAAAAAw/9oACAEBAAY/Ah//xAAaEAABBQEAAAAAAAAAAAAAAAABABARIDFR/9oACAEBAAE/IYFuI43/2gAMAwEAAgADAAAAEADHAP/EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8QH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8QH//EACAQAAEEAAcBAAAAAAAAAAAAAAEAESExEEFxgZGx0fD/2gAIAQEAAT8QAi7FzFpmvtNrygBHiymNl9SN4j//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"scan results\"\n        title=\"\"\n        src=\"/static/303844ddea00bcb177f38ea50a1773ee/65069/scanresult.jpg\"\n        srcset=\"/static/303844ddea00bcb177f38ea50a1773ee/6f81f/scanresult.jpg 270w,\n/static/303844ddea00bcb177f38ea50a1773ee/09d21/scanresult.jpg 540w,\n/static/303844ddea00bcb177f38ea50a1773ee/65069/scanresult.jpg 892w\"\n        sizes=\"(max-width: 892px) 100vw, 892px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>And you when you click on issues you can see them by category and also the rules used to perform the scan.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/50e9086321a0ebdc46828894b5557fd9/3bd77/errordetails.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 68.14814814814815%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAOABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAduxKB//xAAUEAEAAAAAAAAAAAAAAAAAAAAg/9oACAEBAAEFAl//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAUEAEAAAAAAAAAAAAAAAAAAAAg/9oACAEBAAY/Al//xAAaEAACAgMAAAAAAAAAAAAAAAAAARARITFx/9oACAEBAAE/IeCsyPSFH//aAAwDAQACAAMAAAAQGz//xAAWEQEBAQAAAAAAAAAAAAAAAAAAARH/2gAIAQMBAT8QkY//xAAVEQEBAAAAAAAAAAAAAAAAAAABEP/aAAgBAgEBPxBn/8QAHBABAAIBBQAAAAAAAAAAAAAAAQARIRAxQZHh/9oACAEBAAE/EGwHBuJmb6jl5pNk5Z//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"scan error details\"\n        title=\"\"\n        src=\"/static/50e9086321a0ebdc46828894b5557fd9/47311/errordetails.jpg\"\n        srcset=\"/static/50e9086321a0ebdc46828894b5557fd9/6f81f/errordetails.jpg 270w,\n/static/50e9086321a0ebdc46828894b5557fd9/09d21/errordetails.jpg 540w,\n/static/50e9086321a0ebdc46828894b5557fd9/47311/errordetails.jpg 1080w,\n/static/50e9086321a0ebdc46828894b5557fd9/3bd77/errordetails.jpg 1171w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>In terms of the speed, I was very happy with the result. It took nearly 2 minutes to scan my entire code base with more than 520 files and thousands line of code.</p>\n<p>In term of the scan result, I would say based on the default rule set and considering that this was the community edition, the results are slightly better than <code class=\"language-text\">tslint</code> or <code class=\"language-text\">codelyzer</code>. I could easily navigate through issues, find out what line of code needed attention. It showed me the results with syntax highlighting and a lo of categories and tags where I could drill down and find what I wanted quickly.</p>\n<p>So go ahead and give it a shot, I am sure you’ll find enough to keep you busy for a while to fix those. And bare in mind that it not only gives you linting errors, it will also give you some security hints based on <a href=\"https://en.wikipedia.org/wiki/OWASP\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OWASP top 10</a> as well.</p>","timeToRead":4,"frontmatter":{"title":"Run code analysis with sonarqube using docker","unformattedDate":"2020-02-23T00:00:00.000Z","date":"Feb 23, 2020","path":"/sonarqube-docker/","author":"Yaser Adel Mehraban","tags":["webdev","showdev","codeanalysis","docker"],"thumbnail":null}}},{"node":{"id":"f64c5989-af81-5c73-a007-dba78afbe6b6","html":"<p>I was working with my docker image for my pet project and suddenly got an error message:</p>\n<!--more-->\n<div class=\"custom-block danger\"><div class=\"custom-block-body\"> client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version.</div></div>\n<p>I just opened a command line and typed:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"40089603475909290000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`\\$ docker version`, `40089603475909290000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-powershell line-numbers\"><code class=\"language-powershell\">$ docker version</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>And guess what? this is the output:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">Client:\r\n  Version:      1.13.0-rc7\r\n  API version:  1.25\r\n  Go version:   go1.7.3\r\n  Git commit:   48a9e53\r\n  Built:        Tue Feb 14 17:56:00 UTC 2017\r\n  OS/Arch:      linux/amd64\r\n\r\nServer:\r\n  Version:      1.13.0-rc7\r\n  API version:  1.25 (minimum version 1.24)\r\n  Go version:   go1.7.3\r\n  Git commit:   48a9e53\r\n  Built:        Tue Feb 14 17:56:00 UTC 2017\r\n  OS/Arch:      linux/amd64&lt;/pre></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Turns out my current version is higher than the error version, so what is going on here.</p>\n<p>The catch is the <code class=\"language-text\">docker-compose</code> file format has been versioned and therefore we should increment the version requested in the <code class=\"language-text\">docker.yml</code> file.</p>\n<p>In any docker-compose file that is used with 1.24 or later version of the docker client, we should request version <code class=\"language-text\">2.1</code>.</p>\n<p>So change your file to look like this and you should be good to go:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">version: '2.1'\r\n\r\n  services:\r\n    webapplication102:\r\n      image: user/myapplication\r\n      build:\r\n        context: .</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Here is the <a href=\"https://github.com/docker/compose/issues/4106\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">issue page</a> on <code class=\"language-text\">github</code> if you need more info.</p>\n<p><strong>Update:</strong></p>\n<p>Version 3 is released, which means you should be able to put 3 instead of 2.1 in your <code class=\"language-text\">docker-compose.yml</code> file.</p>","timeToRead":1,"frontmatter":{"title":"Are you facing docker version error?","unformattedDate":"2017-02-15 18:16","date":"Feb 15, 2017","path":null,"author":"Yaser Adel Mehraban","tags":["docker","docker-compose"],"thumbnail":null}}}]}},"pageContext":{"tag":"docker"}},"staticQueryHashes":[],"slicesMap":{}}