title: Refused to connect when accessing phpmyadmin on docker container
body: <p>I use docker-compose to setup my application with below app.yml:</p>
  
  <pre><code>version: '2'
  services:
      hdback-app:
          image: xxxx:0.0.3
          environment:
              - SPRING_PROFILES_ACTIVE=prod,swagger
              - SPRING_DATASOURCE_URL=jdbc:mysql://db:3306/sample?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false
              - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application
              - SPRING_DATA_ELASTICSEARCH_CLUSTER_NODES=sample-elasticsearch:9300
          ports:
              - 8080:8080
      db:
          extends:
              file: mysql.yml
              service: db
      nginx:
          extends:
              file: nginx.yml
              service: nginx
      hdback-elasticsearch:
          extends:
              file: elasticsearch.yml
              service: hdback-elasticsearch
      phpmyadmin:
          image: phpmyadmin/phpmyadmin
          depends_on:
              - db
          ports:
              - 8081:8081
  </code></pre>
  
  <p>The application is installed on Centos 7, the nginx.yml is as below:</p>
  
  <pre><code>services:
      nginx:
          image: nginx:1.14.0
          volumes:
              - ./../www:/usr/share/nginx/html
              - ./nginx/site.conf:/etc/nginx/conf.d/default.conf
          ports:
              - "80:80"
  </code></pre>
  
  <p>And the site.conf is as below:</p>
  
  <pre><code>server {
      listen 80;
      index index.html;
      server_name localhost;
      error_log  /var/log/nginx/error.log;
  
      location / {
          root /usr/share/nginx/html;
      }
      location /api {
          proxy_pass http://www.sample.com:8080/api;
      }
      location /management {
          proxy_pass http://www.sample.com:8080/management;
      }
      location /v2 {
         proxy_pass http://www.sample.com:8080/v2;
      }
      location /swagger-ui {
          proxy_pass http://www.sample.com:8080/swagger-ui;
      }
      location /swagger-resources {
          proxy_pass http://www.sample.com:8080/swagger-resources;
      }
  }
  </code></pre>
  
  <p>When I up the application, www.sample.com works, that is, port 80 works, however, when I want to access phpmyadmin, the browser says:</p>
  
  <pre><code>sample.com refused to connect
  </code></pre>
  
  <p>I disable the firewall, and ensure the port 8081 is listening, below is when I issue:</p>
  
  <pre><code>docker ps
  CONTAINER ID        IMAGE                                                    COMMAND                   CREATED             STATUS              PORTS                                            NAMES
  5a18390de5e1        phpmyadmin/phpmyadmin                                    "/run.sh supervisord…"    24 hours ago        Up 24 hours         80/tcp, 9000/tcp, 0.0.0.0:8081-&gt;8081/tcp         docker_phpmyadmin_1
  1de715bb735d        nginx:1.14.0                                             "nginx -g 'daemon of…"    24 hours ago        Up 24 hours         0.0.0.0:80-&gt;80/tcp                               docker_nginx_1
  6b748cb592ec        elasticsearch:2.4.6                                      "/docker-entrypoint.…"    24 hours ago        Up 24 hours         0.0.0.0:9200-&gt;9200/tcp, 0.0.0.0:9300-&gt;9300/tcp   docker_hdback-elasticsearch_1
  dd3de12c3ff4        mysql:5.7.20                                             "docker-entrypoint.s…"    24 hours ago        Up 24 hours         0.0.0.0:3306-&gt;3306/tcp                           docker_db_1
  c0ad30aabd3c        xxxx:0.0.3   "/bin/sh -c 'echo \"T…"   24 hours ago        Up 24 hours         0.0.0.0:8080-&gt;8080/tcp                           docker_hdback-app_1
  </code></pre>
  
  <p>I have spent almost half day to find solution but no luck, what is going wrong?</p>