Re: Running Pyro (nameserver for now) in a Docker container

Giovanni Porcari <[email protected]> Wed, 16 Jul 2014 23:07:00 +0200
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
> Il giorno 16/lug/2014, alle ore 21:14, Steven Pav <[email protected]> ha scritto:
> 
> Thanks for the reply, and I suspect you are right. I have tried to specify 
> '--bcport=6433' to the nameserver running in the container, and run the 
> container with -p 0.0.0.0:6433:6433/udp . Nevertheless, I cannot access the 
> nameserver. I am not as familiar with the unix socket approach. Could you 
> elaborate on how that would work? For the nameserver, it seems clear that 
> one would use
> --unixsocket=UNIXSOCKET
> However, I am not sure how to create the socket and how to connect it 
> between the container and host. Any help appreciated,


About nameserver. I am not sure about the way it works but remember
that in a docker container you have to take care of any network connection.
So you have to know the port that must be visible outside the container.

I will try to explain you how i use pyro4 using sockets in docker and not
using name server.

I have a container that i use as shared data: you can create it with:

sudo docker run --name shared_sockets -d -v /mysockets ubuntu:latest /bin/false

then you can stop it with:
sudo docker stop shared_sockets

You can now start the containers that you need adding --volumes-from shared_sockets.

In this way all containers will share the folder /mysockets.

Now in container 'foo' you have a Pyro server and you can start it with:
daemon = Pyro4.Daemon(unixsocket='/mysockets/fooservice.sock')
uri = daemon.register(myobject,'FooDaemon')
Uri will be 'FooDaemon@./u:/mysockets/fooservice.sock'

To connect to it you will use Pyro4.Proxy('FooDaemon@./u:/mysockets/fooservice.sock')

In the same way you can create many container and each of them
will use a specific socket so you can know the exact uri
with no need of a name server as the uri will no longer depends
on a port but just on a name that you can create with your rules.

I hope that will be helpful for you.

Ciao

G


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds