Vijay
Vijay

Reputation: 41

docker-compose issue with hadoop + hbase setup

I've setup docker containers for hadoop and hbase without a problem. I'm now trying to put them together and run them in a sequence using docker-compose.

version: '2'
services:
 hadoop:
  image: hadoop:2.6
  container_name: hadoop-compose
  ports:
  - "50070:50070"  
 hbase:
 image: hbase:0.98
 container_name: hbase-compose
 ports:
 - "9000:9000"
 command: bash -c "while ! nc -v -z -w 3 172.17.0.2 50070; do echo waiting for hadoop; sleep 5; done; sh /opt/hbase-server.sh"
 depends_on:
 - hadoop
 links:
 - hadoop

I want hbase to initialize after hadoop has completed. For this I defined a simple command that pings the hadoop container and if successful , proceeds to run the hbase-server script.

I don't understand why the hbase container is unable to ping hadoop instead it throws this error

nc: connect to 172.17.0.2 port 50070 (tcp) timed out: Operation now in progress

If I start the containers separately using docker and ping hadoop from hbase , it connects alright. Is there an issue with the compose file or did I mess up the command script ?

P.S : I've also referred this post (wait for container X before Y)

Thanks

Upvotes: 0

Views: 710

Answers (1)

sager89
sager89

Reputation: 980

  1. Check what the name of your docker network is with a docket network ls

  2. Inspect that network to verify your services are there with a docker network inspect "name of your network" The name of the network should be the name of the directory in which the docker-compose file lives since you're using version 2.

  3. Assuming your services exist in the same network, ensure they sufficiently retry their connections. Using links or depends_on only controls order of startup, but doesn't necessarily mean one app will wait for another to fully initialize. https://docs.docker.com/compose/startup-order/

P.S. I don't believe you need depends_on if you specify Links. https://docs.docker.com/compose/compose-file/#links

Upvotes: 2

Related Questions