title: HBase 1.2.1 standalone in Docker unable to connect
body: <p>I want to connect to HBase running in standalone in a docker, using Java and the HBase API</p>
  
  <p>I use this code to connect :</p>
  
  <pre><code>Configuration config = HBaseConfiguration.create();
  config.set("hbase.zookeeper.quorum", "163.172.142.199");
  config.set("hbase.zookeeper.property.clientPort","2181");
  HBaseAdmin.checkHBaseAvailable(config);
  </code></pre>
  
  <p>Here is my /etc/hosts file</p>
  
  <pre><code>127.0.0.1   localhost
  XXX.XXX.XXX.XXX hbase-srv
  </code></pre>
  
  <p>Here is the /etc/hosts file from my docker (named hbase-srv)</p>
  
  <pre><code>XXX.XXX.XXX.XXX hbase-srv
  </code></pre>
  
  <p>With this configuration, I get a connection refused error :</p>
  
  <pre><code> INFO | Initiating client connection, connectString=163.172.142.199:2181 sessionTimeout=90000 watcher=hconnection-0x6aba2b860x0, quorum=163.172.142.199:2181, baseZNode=/hbase
   INFO | Opening socket connection to server 163.172.142.199/163.172.142.199:2181. Will not attempt to authenticate using SASL (unknown error)
   INFO | Socket connection established to 163.172.142.199/163.172.142.199:2181, initiating session
   INFO | Session establishment complete on server 163.172.142.199/163.172.142.199:2181, sessionid = 0x15602f8d8dc0002, negotiated timeout = 40000
   INFO | Closing zookeeper sessionid=0x15602f8d8dc0002
   INFO | Session: 0x15602f8d8dc0002 closed
   INFO | EventThread shut down
  org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.net.ConnectException: Connection refused
      at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$StubMaker.makeStub(ConnectionManager.java:1560)
      at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionManager.java:1580)
      at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.getKeepAliveMasterService(ConnectionManager.java:1737)
      at org.apache.hadoop.hbase.client.ConnectionManager$HConnectionImplementation.isMasterRunning(ConnectionManager.java:948)
      at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:3159)
      at hbase.Benchmark.main(Benchmark.java:26)
  </code></pre>
  
  <p>However, if I remove the lines <code>XXX.XXX.XXX.XXX hbase-srv</code> from both <code>/etc/hosts</code> files I get the error <code>unknown host : hbase-srv</code></p>
  
  <p>I have also checked, I can successfully <em>telnet</em> to my hbase docker on the client port.</p>
  
  <p>On the docker, all the ports used by HBase are opened and binded to the same number (60000 on 60000, 2181 on 2181, etc).</p>
  
  <p>I also wanted to add that all was fine when I used this configuration on localhost.</p>
  
  <p>If you can't give me an answer to my problem, could you at least give me a procedure to deploy a standalone hbase on a docker.</p>
  
  <p>UPDATE : Here is my Docker file</p>
  
  <pre><code>FROM java:openjdk-8
  
  ADD hbase-1.2.1 /hbase-1.2.1
  
  WORKDIR /hbase-1.2.1
  # ZooKeeper
  EXPOSE 2181
  
  # HMaster
  EXPOSE 60000
  
  # HMaster Web
  EXPOSE 60010
  
  # RegionServer
  EXPOSE 60020
  
  # RegionServer Web
  EXPOSE 60030
  
  EXPOSE 16010
  
  RUN chmod 755 /hbase-1.2.1/bin/start-hbase.sh
  CMD ["/hbase-1.2.1/bin/start-hbase.sh"]
  </code></pre>
  
  <p>My HBase shell is working, I also tried to open the port using iptables for tcp and udp but still the same problem</p>