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
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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: