Wigny
Connect Livebook to a Elixir node running in a Docker container
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?
Marked As Solved
jonatanklosko
** Hostname api is illegal **
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.
Also Liked
Wigny
That worked like a charm! Many thanks!
Leaving the full command here for future readers:
docker-compose run \
--rm \
--service-ports \
--name api \
api \
iex --name test@api.$API_NETWORK --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_DEFAULT_RUNTIME="attached:test@api.$API_NETWORK:mycookie" \
ghcr.io/livebook-dev/livebook:nightly
Popular in Questions
Other popular topics
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
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








