In-container xml-rpc Connection refused

Within a container, I have a python module that calls a binary (within the same container) via xml-rpc; the connection is refused .

The RPC call string is " http://localhost:9123 " . I have already tried EXPOSEing ports 9123 and 80, with no success.

I have already verified that the binary starts in RPC server mode, when called from command line.

The repository can be found here : https://github.com/ocramz/jupyter-docker-pymol

What might be happening? Thank you in advance

Stack trace follows:


ConnectionRefusedError Traceback (most recent call last)
in ()
----> 1 pymol.start()

/usr/local/lib/python3.4/dist-packages/ipymol/core.py in start(self)
30 ‘http://%s:%d’ % (self.host, self.port)
31 )
—> 32 self._server.ping()
33
34 def do(self, cmd):

/usr/lib/python3.4/xmlrpc/client.py in call(self, *args)
1096 return _Method(self.__send, “%s.%s” % (self.__name, name))
1097 def call(self, *args):
-> 1098 return self.__send(self.__name, args)
1099
1100 ##

/usr/lib/python3.4/xmlrpc/client.py in __request(self, methodname, params)
1435 self.__handler,
1436 request,
-> 1437 verbose=self.__verbose
1438 )
1439

/usr/lib/python3.4/xmlrpc/client.py in request(self, host, handler, request_body, verbose)
1138 for i in (0, 1):
1139 try:
-> 1140 return self.single_request(host, handler, request_body, verbose)
1141 except OSError as e:
1142 if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED,

/usr/lib/python3.4/xmlrpc/client.py in single_request(self, host, handler, request_body, verbose)
1150 # issue XML-RPC request
1151 try:
-> 1152 http_conn = self.send_request(host, handler, request_body, verbose)
1153 resp = http_conn.getresponse()
1154 if resp.status == 200:

/usr/lib/python3.4/xmlrpc/client.py in send_request(self, host, handler, request_body, debug)
1262 headers.append((“User-Agent”, self.user_agent))
1263 self.send_headers(connection, headers)
-> 1264 self.send_content(connection, request_body)
1265 return connection
1266

/usr/lib/python3.4/xmlrpc/client.py in send_content(self, connection, request_body)
1292
1293 connection.putheader(“Content-Length”, str(len(request_body)))
-> 1294 connection.endheaders(request_body)
1295
1296 ##

/usr/lib/python3.4/http/client.py in endheaders(self, message_body)
1082 else:
1083 raise CannotSendHeader()
-> 1084 self._send_output(message_body)
1085
1086 def request(self, method, url, body=None, headers={}):

/usr/lib/python3.4/http/client.py in _send_output(self, message_body)
920 msg += message_body
921 message_body = None
–> 922 self.send(msg)
923 if message_body is not None:
924 # message_body was not a string (i.e. it is a file), and

/usr/lib/python3.4/http/client.py in send(self, data)
855 if self.sock is None:
856 if self.auto_open:
–> 857 self.connect()
858 else:
859 raise NotConnected()

/usr/lib/python3.4/http/client.py in connect(self)
832 “”“Connect to the host and port specified in init.”""
833 self.sock = self._create_connection((self.host,self.port),
–> 834 self.timeout, self.source_address)
835
836 if self._tunnel_host:

/usr/lib/python3.4/socket.py in create_connection(address, timeout, source_address)
510
511 if err is not None:
–> 512 raise err
513 else:
514 raise error(“getaddrinfo returns an empty list”)

/usr/lib/python3.4/socket.py in create_connection(address, timeout, source_address)
501 if source_address:
502 sock.bind(source_address)
–> 503 sock.connect(sa)
504 return sock
505

ConnectionRefusedError: [Errno 111] Connection refused

localhost in container is different than localhost on host computer. Sounds like you need to run the RPC server in a separate container and put them on the same docker network, then access the RPC server container using the DNS alias based on its container name.