Wigny
Hey folks, I would like help to connect Livebook to an Elixir node running in a Docker container.
To run the container I usually do
docker-compose run --rm --service-ports api iex -S mix
and Livebook
docker run -p 8080:8080 -p 8081:8081 --pull always -u $(id -u):$(id -g) -v $(pwd):/data ghcr.io/livebook-dev/livebook:nightly
as described in the docs.
Now I want to attach a new notebook to the running app. If I got it right, for the node to be visible to Livebook, it must be running in the same network and have a known RELEASE_NODE and RELEASE_COOKIE. For that, I tried following this gist, this thread and also this discussion, but got no luck.
This is what I tried:
docker-compose run \
--rm \
--service-ports \
-e RELEASE_DISTRIBUTION="name" \
-e RELEASE_NODE="api@127.0.0.1" \
-e RELEASE_COOKIE="mycookie" \
api \
iex --name api@127.0.0.1 --cookie mycookie -S mix
docker run \
-p 8080:8080 \
-p 8081:8081 \
--pull always \
-u $(id -u):$(id -g) \
-v $(pwd):/data \
--network $API_NETWORK \
-e LIVEBOOK_NODE="livebook@127.0.0.1" \
-e LIVEBOOK_DISTRIBUTION=name \
-e LIVEBOOK_DEFAULT_RUNTIME="attached:api@127.0.0.1:mycookie" \
ghcr.io/livebook-dev/livebook:nightly
What am I missing?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex











First 8 of 8 Posts
ruslandoga
I think
127.0.0.1might be the issue (Docker typically uses172.x.x.x/16subnets). Have you tried using container names for hostnames?jonatanklosko
Hey @Wigny, I think @ruslandoga is correct, the
iexnode needs to beapi@[CONTAINER_NAME], as mentioned in the gist.Sidenote:
you don’t need the
RELEASE_*env vars, they only apply to releases, but not foriex -S mix(and you already set--nameand--cookieinstead)LIVEBOOK_DISTRIBUTION=nameno longer has any effect, so you can skip itarcanemachine
Because of how they’re exposing the ports
8080:8080, I think this will expose them like any other service on the host (i.e.nmap localhostwould show port 8080 as being open). If the syntax was just8080, then I believe your assumption would be correct. (Might be worth a shot also, plus better to isolate the containerized service in its own Docker network… Just gotta make sure the container name is correct then.)Also could
ruslandoga
Interesting, I’ll try it out.
ruslandoga
I wasn't able to access another container in the same bridge network via localhost.
Would you be able to modify my example to make it work?
Wigny
Thanks for the tips!
So I got rid of the unnecessary env vars and started giving a name to my container:
but when trying to attach Livebook, I’m getting in the logs
** Hostname api is illegal **.Given our
apiapp has a/api/pingendpoint, I tried checking that within the Livebook container we can access the endpoint usingwget. So by attaching to the Livebook container runningdocker exec -it $CONTAINERID bashand executingwget -qO- localhost:4000/api/pingorwget -qO- api:4000/api/pingI had no response, butwget -qO- host.docker.internal:4000/api/pingorwget -qO- 172.17.0.1:4000/api/pingreturnspong…jonatanklosko
Ah, when running using long names by specifying
--name(which Livebook now always does as well), if the hostname needs to be either an IP or a fully qualified domain name (basically, it needs at least one dot). Looks like it’s only validated when trying to connect to another node, not when starting the node itself.One way would be for the container name to include a dot, but I believe that can also just use
{container_name}.{network_name}as the hostname and the internal Docker DNS will resolve that correctly.Wigny
That worked like a charm! Many thanks!
Leaving the full command here for future readers: