title: Sonarqube in Docker Compose request error 400 using container name
body: <p>I have a deploy in Docker Compose using a custom network with Jenkins, Sonarqube and Posgresql. I can ping sonarqube using its name:</p>
  <pre><code>$ping sonarqube
  PING sonarqube (172.22.0.6): 56 data bytes
  64 bytes from 172.22.0.6: seq=0 ttl=64 time=0.112 ms
  </code></pre>
  <p><code>Resolve to IP 172.22.0.6</code></p>
  <p>When I use its name in url <code>http://sonarqube:9000</code> I get 400 Bad Request.</p>
  <pre><code>$curl http://sonarqube:9000
  &lt;!doctype html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;HTTP Status 400 – Bad Request&lt;/title&gt;&lt;style type=&quot;text/css&quot;&gt;body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 400 – Bad Request&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  <p>But if I use IP address, it works!</p>
  <pre><code>$curl http://172.22.0.6:9000
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  
  &lt;head&gt;
      &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; charset=&quot;UTF-8&quot; /&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; href=&quot;/apple-touch-icon.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;57x57&quot; href=&quot;/apple-touch-icon-57x57.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;60x60&quot; href=&quot;/apple-touch-icon-60x60.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;72x72&quot; href=&quot;/apple-touch-icon-72x72.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;76x76&quot; href=&quot;/apple-touch-icon-76x76.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;114x114&quot; href=&quot;/apple-touch-icon-114x114.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;120x120&quot; href=&quot;/apple-touch-icon-120x120.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;144x144&quot; href=&quot;/apple-touch-icon-144x144.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;152x152&quot; href=&quot;/apple-touch-icon-152x152.png&quot;&gt;
      &lt;link rel=&quot;apple-touch-icon&quot; sizes=&quot;180x180&quot; href=&quot;/apple-touch-icon-180x180.png&quot;&gt;
      &lt;link rel=&quot;icon&quot; type=&quot;image/x-icon&quot; href=&quot;/favicon.ico&quot;&gt;
      &lt;meta name=&quot;application-name&quot; content=&quot;SonarQube&quot; /&gt;
      &lt;meta name=&quot;msapplication-TileColor&quot; content=&quot;#FFFFFF&quot; /&gt;
      &lt;meta name=&quot;msapplication-TileImage&quot; content=&quot;/mstile-512x512.png&quot; /&gt;
      &lt;title&gt;SonarQube&lt;/title&gt;
  
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/js/outV7HKTALN.css&quot;&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id=&quot;content&quot;&gt;
          &lt;div class=&quot;global-loading&quot;&gt;
              &lt;i class=&quot;spinner global-loading-spinner&quot;&gt;&lt;/i&gt; 
              &lt;span class=&quot;global-loading-text&quot;&gt;Loading...&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;script&gt;
          window.baseUrl = '';
          window.serverStatus = 'UP';
          window.instance = 'SonarQube';
          window.official = true;
      &lt;/script&gt;
  
      &lt;script type=&quot;module&quot; src=&quot;/js/outZA7ASMV3.js&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>I need to do a configuration in SonarQube or user a proxy? I want to use its name because containers are created and destroyed, Thanks</p>
  <p><strong>EDIT</strong> Docker Compose File</p>
  <pre><code>version: &quot;3.5&quot;
  
  services:
  
    gitlab_promad:
      image: 'gitlab/gitlab-ce:latest'
      container_name: 'gitlab_promad'
      restart: always
      ports:
        - '80:80'
        - '443:443'
        - '22:22'
      volumes:
        - '/srv/gitlab/config:/etc/gitlab'
        - '/srv/gitlab/logs:/var/log/gitlab'
        - '/srv/gitlab/data:/var/opt/gitlab'
      networks:
        - promad_devsecops
        
    mobsf_promad:
      image: 'opensecurity/mobile-security-framework-mobsf:latest'
      container_name: 'mobsf_promad'
      restart: always
      networks:
        - promad_devsecops
  
    jenkins_promad:
      image: 'test:v3'
      container_name: 'jenkins_promad'
      restart: always
      privileged: true
      user: root
      ports:
        - '8080:8080'
      volumes:
        - '/srv/jenkins:/var/jenkins_home'
      networks:
        - promad_devsecops
    
    sonarqube:
      image: sonarqube:community
      container_name: 'sonarqube'
      depends_on:
        - db_promad
      environment:
        SONAR_JDBC_URL: jdbc:postgresql://db_promad:5432/sonar
        SONAR_JDBC_USERNAME: sonar
        SONAR_JDBC_PASSWORD: sonar
      volumes:
        - /srv/sonarqube/data:/opt/sonarqube/data
        - /srv/sonarqube/extensions:/opt/sonarqube/extensions
        - /srv/sonarqube/logs:/opt/sonarqube/logs
      ports:
        - '9000:9000'
      networks:
        - promad_devsecops
  
    db_promad:
      image: postgres:12
      container_name: 'db_promad'
      environment:
        POSTGRES_USER: sonar
        POSTGRES_PASSWORD: sonar
      volumes:
        - /srv/postgresql:/var/lib/postgresql
        - /srv/postgresql/data:/var/lib/postgresql/data
      networks:
        - promad_devsecops
  
  networks:
    promad_devsecops:
      name: 'promad_devsecops'
  </code></pre>