Git Product home page Git Product logo

erl_dist_docker's Introduction

Erlang distribution between Docker containers

Using built-in Erlang distribution between Erlang nodes deployed in Docker containers. Project is aiming to use all functionality of built-in distribution including RPC calls, MNesia replication.

Distributed port mapping and Docker

  • Erlang nodes will start distribution when a node name was passed with -name or -sname option. The nodes will look for epmd on 127.0.0.1:4369 and fail with error nodistribution if epmd is not listening at that address and port.
  • To set up a distributed cluster of Erlang nodes, they have to have their cookie and epmd port number matched, and each node must have a unique node name.
  • Docker containers running epmd can't expose their port 4369 as it will lead to a port collision, when containers run on a single host.
  • Erlang nodes started in containers should start their epmd inside their containers.
  • To enable networking without restrictions between two Docker containers, the containers need to be part of the same user defined Docker network. (Using networks provided by Docker such as none, host, bridge won't work in this context.)
  • Communication between two Erlang nodes in two Docker containers:
    • Erlang nodes need to be started with shortname (-sname) option. In this case the hostname will be dynamically distributed and will inherit the Docker container ID. If the hostname is set, two nodes will not see each other.
  • Limitation: Since the dynamic binding, manual intervention is obligatory so the nodes will discover each other. This means that in one's shell net_adm:ping(OthersFullName). needs to be run.
  • current problems, possible fields to explore:
    • connection between an Erlang node in Docker container and a stand-alone Erlang node is not possible - they are not on the same Docker network
    • two Docker containers with Erlang nodes on two hosts - same Docker network problem - Kubernetes will be needed to overcome this limitation

Minimal success example

docker network create erlnet
docker run -it --rm --net erlnet erlang sh -c 'erl -sname snode -setcookie cookie'

or using Dockerfile provided in this project

docker network create erlnet
cd docker_erlang
docker build -t erl . erldock
docker run -it --rm --net erlnet erldock sh -c 'erl -sname snode -setcookie cookie'

Building and running the example Erlang project

A rebar3 project named node has been setup as an example Erlang application. A dev mode release can be generated and then started with the provided start script.

cd node
rebar3 release
_build/default/rel/node/bin/node console

Multiple nodes on the localhost

Building an image with the example application

cd erlang_compose
docker build -t erldock .

Start two nodes with docker-compose

Starting an O&M node

docker run --net <network_name> -it --rm erldock sh -c '_build/default/rel/node/bin/node console'

erl_dist_docker's People

Contributors

khetzl avatar kszava avatar

Watchers

James Cloos avatar Qiang Guo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.