Search code examples
luatarantoolcartridgetarantool-cartridge

Should I setup network address with the Tarantool Cartridge application with docker?


When I use the docker pack for an application, how should I configure network addresses?


Solution

  • The logic of network connectivity in tarantool cartridge doesn't depend on whether you use regular virtual machines, or Docker. You need your tarantool instances to be able to reach each other through TCP and UDP.

    In Docker it means either:

    Setting up containers on the same internal network

    And using internal network addresses to connect instances together. By default, instances on the same internal network will be able to reach each other on any tcp/udp ports. If you want multiple machines to share the same internal network, you may configure Docker Swarm, which will give you a so-called "overlay network" that spans multiple machines.

    Binding to host's port

    When running a container, you can pass -p 3301:3301/tcp -p 3301:3301/udp to docker run. It will expose a port from container to the external network on the host. Be very careful to always expose a udp port, because otherwise instances won't be able to talk to each other through the gossip protocol.

    In addition to that, since you change the public address of your instances to be your host's IP and not the internal container's IP, you also need to specify additional parameter that changes the advertise URI of the tarantool instance. You can do that with the following option to docker run: -e TARANTOOL_ADVERTISE_URI=<your_host_ip>:3301.