简体   繁体   中英

docker-compose network / ports handling

I have two components: hbas&ookeeper as single container and hbase-printer (my java code) in my host. My goal is to print the content of some hbase table. The problem is that the connection to 2181 (zookeeper port) succeed but than it looks like I'm getting directed to side randomly port to communicate and this port is not exposed. I'm using docker-compose.yml :

version: '2'
services:
  hbase:
    image: dy1-dockerv2-local.jfrog.io/hbase:latest
    restart: always
    hostname: hbase-docker
    ports:
      - "60010:60010"
      - "60000:60000"
      - "60020:60020"
      - "60030:60030"
      - "9095:9095"
      - "8085:8085"
      - "8080:8080"
      - "2181:2181"
      - "9091:9091"
      - "9090:9090"
    expose:
      - "9091"
      - "2181"
    volumes:
      - ./data/hbase:/data
      - ./logs/hbase/:/opt/hbase/logs
    network_mode: "bridge"

In my java logs I'm getting:

23-02-2017 09:29:54,413 INFO [ClientCnxn]: [main-SendThread(localhost:2181)] Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x15a69d8a7a30006, negotiated timeout = 40000
23-02-2017 09:30:16,955 INFO [HBaseRPC]: [main] Problem connecting to server: hbase-docker/172.17.0.2:39521

In my host I can see the listening ports:

$ netstat -na | grep LISTEN
tcp6       0      0  ::1.2181               *.*                    LISTEN
tcp4       0      0  *.2181                 *.*                    LISTEN
tcp6       0      0  ::1.8080               *.*                    LISTEN
tcp4       0      0  *.8080                 *.*                    LISTEN
tcp6       0      0  ::1.8085               *.*                    LISTEN
tcp4       0      0  *.8085                 *.*                    

(and the rest of the ports I've defined in my docker-compose.yml file

And in the container I see:

root@hbase-docker:/# netstat -na | grep LISTEN
tcp6       0      0 172.17.0.2:39521        :::*                    LISTEN
tcp6       0      0 :::2181                 :::*                    LISTEN
tcp6       0      0 :::60010                :::*                    LISTEN
tcp6       0      0 172.17.0.2:32785        :::*                    LISTEN
tcp6       0      0 :::43189                :::*                    LISTEN

I see that the side port 39521 is available inside the container but not exposed to the host. I cannot add it to my docker-compose.yml because it changed randomly (looks like something between 30000-50000). How can I expose the random port to my host?

You are most like facing https://issues.apache.org/jira/browse/HBASE-10289 , which was fixed in 0.99.0 and 0.98.4. As of the comments on the answer, you are still on an old version of hbase, probably < 0.99.0.

You should try to use a newer version of hbase. You'll find one on the Docker Hub for example: https://hub.docker.com/r/dajobe/hbase/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM