1

I created a Oracle Linux VM (ipAddr 192.168.10.2) on my windows machine.

On this VM, I further created a kvlite docker container.

In Dockerfile following is CMD issued:

CMD ["java", "-jar", "lib/kvstore.jar", "kvlite"]

Once kvlite docker container was created I ran following commands on my VM:

$ docker run --name nosql-container -d kvlite:latest

$ docker exec -it nosql-container bash

On the container bash prompt I try to ping my client using following command (but using VM IpAddress and not localhost):

# java -jar lib/kvstore.jar ping -port 5000 -host 192.168.10.2

This however throws an exception

Picked up _JAVA_OPTIONS: -Djava.security.egd=file:/dev/./urandom

Could not connect to registry at 192.168.10.2:5000 Unable to connect to the storage node agent at host 192.168.10.2, port 5000, which may not be running; nested exception is:

java.rmi.ConnectException: Connection refused to host: 192.168.10.2; nested exception is:

java.net.ConnectException: Connection refused

Can't find store topology: Could not contact any RepNode at: [192.168.10.2:5000]

But, things works fine when I use -host as localhost instead i.e.,

# java -jar lib/kvstore.jar ping -port 5000 -host localhost

To resolve this issue I tried following:

  • I stopped my kvlite docker container

  • Changed config.xml ($KVROOT/config.xml) for value hostname to IpAddress

  • Re-Started my kvlite docker container, but this didn't helped, container couldn't start

Next I tried to re-create a new docker image for kvlite issuing below CMD:

CMD ["java", "-jar", "lib/kvstore.jar", "kvlite", "-host", "192.168.10.2", "-port", "5000"]

But here also when I tried starting kvlite docker container, it didn't start.

I even verified my /etc/hosts file for entry of IpAddress-192.168.10.2.

Any help appreciated in advance.

Community
  • 1
  • 1
Anurag
  • 51
  • 3

1 Answers1

0

Docker uses its own virtual network on the VM.

The default network docker uses has an IP-Range of 172.17.x.x, so the Container you started has its own IP in that network range.

To find the IP of your Container type ifconfig after logging into the Container with

$ docker exec -it nosql-container bash

You can use the Container IP to address the Container from inside the Container.

If you want to reach the process from outside the container over the IP of the VM you need to expose the port (with -p) when starting the docker container.

$ docker run --name nosql-container -p 5000:5000 -d kvlite:latest

You can find more about Docker default networking here.

An alternative approach could be to share the WM network with your container, by specifying --net=host.

$ docker run --name nosql-container --net=host -d kvlite:latest
  • Yes its "172.17.0.2", what I need is to access this nosql db from Java Client. – Anurag Oct 24 '16 at 11:17
  • Thanks, yes virtual network ip is "172.17.0.2", but what I need is to access this kvlite db from Java Client class remotely. You can see my issue at: [link](http://stackoverflow.com/questions/40154567/docker-oracle-kv-faultexception-could-not-contact-any-repnode) IPAddress "172.17.0.2" is not pingable remotely, Is it possible to ping this ipAddress i.e., "172.17.0.2" remotely ? I tried --net=192.168.10.2 but it couldn't start nosql-container. – Anurag Oct 24 '16 at 11:31
  • you should be able to use "--net=host" instead of the – Malte Lauenroth Oct 25 '16 at 16:44
  • Yes --net=host resolved this issue. First I wrongly tried using --net=192.168.10.2 but instead "host" should be used. Thanks – Anurag Oct 26 '16 at 06:40