pyzmq-docker | Micro-services as modules with Docker and pyzmq | Microservice library
kandi X-RAY | pyzmq-docker Summary
kandi X-RAY | pyzmq-docker Summary
Example repository to demonstrate how you can turn Python scripts into micro-services in Docker containers, which can communicate over ZeroMQ. The examples here can be run as just Python-Python, Docker-Docker (docker-compose) or Docker-Python (docker run). Examples are using a Publisher-Subscriber pattern to communicate. This means that the publisher micro-service just send messages out to a port, without knowing who is listening and a subscriber micro-service receiving data, without knowing where the data comes from. With ZeroMQ, only 1 micro-service can socket.bind(url) to 1 address. However, you can have unlimited micro-services socket.connect(url) to an address. This means that you can either have many-pub to 1-sub (examples in this Git repo) or 1-pub to many-sub on 1 ip:port combination.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Publish data to subscriber
- Subscribe to a ZeroMQ socket
pyzmq-docker Key Features
pyzmq-docker Examples and Code Snippets
Community Discussions
Trending Discussions on pyzmq-docker
QUESTION
I want to build a modularized system with modules communicating over ZeroMQ. To improve usability, I want to Dockerize (some) of these modules, so that users don't have to setup an environment. However, I cannot get a dockerized publisher to have its messaged received by a non-dockerized subscriber.
System- Ubuntu 18.04
- Python 3.7
- libzmq version 4.2.5
- pyzmq version is 17.1.2
- Docker version 18.09.0, build 4d60db4
zmq_sub.py
...ANSWER
Answered 2018-Dec-17 at 14:51This is mostly a docker networking question, and isn't specific to pyzmq or zeromq. You would have the same issues with anything trying to connect from a container to the host.
To be clear, in this example, you have a server running on the host (zmq_sub.py, which calls bind), and you want to connect to it from a client running inside a docker container (zmq_pub.py).
Since the docker container is the one connecting, you don't need to do any docker port exposing or forwarding. EXPOSE and forwarding ports are only for making it possible to connect to a container (i.e. bind
is called in the container), not to make outbound connections from a container, which is what's going on here.
The main thing here is that when it comes to networking with docker, you should think of each container as a separate machine on a local network. In order to be connectable from other containers or the host, a service should bind onto all interfaces (or at least an accessible interface). Binding on localhost in a container means that only other processes in that container should be able to talk to it. Similarly, binding localhost on the host means that docker containers shouldn't be able to connect.
So the first change is that your bind url should be:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pyzmq-docker
Docker Toolbox for Windows 7/8/10 Home
Docker for Windows 10 Pro, Enterprise or Education
Ubuntu: Docker and docker-compose and sudo usermod -a -G docker $USER
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page