{"id":29566739,"url":"https://github.com/cynicdog/elixir-in-container","last_synced_at":"2026-04-16T12:02:09.700Z","repository":{"id":301880693,"uuid":"1010566620","full_name":"CynicDog/Elixir-In-Container","owner":"CynicDog","description":"Cloud-native Elixir templates 🧑🏻‍💻","archived":false,"fork":false,"pushed_at":"2025-07-08T12:36:59.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-29T07:37:30.713Z","etag":null,"topics":["docker","elixir"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CynicDog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-29T10:55:00.000Z","updated_at":"2025-07-08T12:37:02.000Z","dependencies_parsed_at":"2025-07-07T00:29:15.454Z","dependency_job_id":"91d6319c-c22a-4c1c-a265-bb6c5105befa","html_url":"https://github.com/CynicDog/Elixir-In-Container","commit_stats":null,"previous_names":["cynicdog/clustering-elixir-container","cynicdog/elixir-in-container"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CynicDog/Elixir-In-Container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CynicDog%2FElixir-In-Container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CynicDog%2FElixir-In-Container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CynicDog%2FElixir-In-Container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CynicDog%2FElixir-In-Container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CynicDog","download_url":"https://codeload.github.com/CynicDog/Elixir-In-Container/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CynicDog%2FElixir-In-Container/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31884929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T11:36:10.202Z","status":"ssl_error","status_checked_at":"2026-04-16T11:36:09.652Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","elixir"],"created_at":"2025-07-18T22:41:14.655Z","updated_at":"2026-04-16T12:02:09.695Z","avatar_url":"https://github.com/CynicDog.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elixir in Container ☁️\n\n## Hello World! \n\u003e This section demonstrates how to run an Elixir app inside a Docker container and interact with it via HTTP and distributed BEAM nodes.\n\n\u003cdetails\u003e \n\n#### Pull image from this repository package \n```bash\ncynocdig@CynicDogs-MacBook % docker pull ghcr.io/cynicdog/containerized_elixir:latest\n```\n\n#### Run Docker container with port 8080 exposed\n```bash\ncynocdig@CynicDogs-MacBook % docker run -p 8080:8080 --rm -d ghcr.io/cynicdog/containerized_elixir:latest\n```\n\n#### httpie to the container..\n```bash\ncynocdig@CynicDogs-MacBook % http :8080/greet\n\nHTTP/1.1 200 OK\ncache-control: max-age=0, private, must-revalidate\ncontent-length: 59\ncontent-type: text/plain; charset=utf-8\ndate: Tue, 08 Jul 2025 12:26:48 GMT\nserver: Cowboy\n\n🚀 Elixir inside a container — greetings from the BEAM!\n```\n\n\u003c/details\u003e\n\n\n## Communicate with an Elixir Node in Docker Container\n\u003e This guide shows how to set up distributed Elixir nodes between your **host machine (macOS)** and a **Docker container** using node names and cookies, and how to call functions remotely.\n\n\u003cdetails\u003e\n  \n### On Host Machine 🧑🏻‍💻 \n\n##### Start a BEAM node on the host machine\n\n```bash\ncynocdig@CynicDogs-MacBook % iex --name host@host.docker.internal --cookie mycookie\n````\n\n### On Docker Container 🐋\n\n##### Run the container with network configuration\n\n```bash\ncynocdig@CynicDogs-MacBook % docker run -it --rm \\\n  --add-host host.docker.internal:host-gateway \\\n  elixir bash\n```\n\n##### Curious about `host.docker.internal`?\n\nIf you check the container’s `/etc/hosts` file, you’ll see something like:\n```bash\nroot@container:/# cat /etc/hosts\n127.0.0.1\tlocalhost\n::1\t        localhost ip6-localhost ip6-loopback\n...\n192.168.65.254\thost.docker.internal\n```\n\u003e That `192.168.65.254 host.docker.internal`  line is a special DNS entry Docker provides to containers to reach the host machine.\n\n##### Start a BEAM node inside the container\n```bash\nroot@3e185f96415a:/# iex --name elixir_node@container --cookie mycookie\n```\n\n##### Connect container node to host node\n```bash\niex(elixir_node@container)1\u003e Node.connect(:'host@host.docker.internal')\n```\n\n### Say Hello to the Host Node!\n\nDefine a module on both the host node:\n\n```elixir\ndefmodule Greet do\n  def say_hello do\n    IO.puts(\"Hello 👋🏻 from #{node()}! 🐋\")\n  end\nend\n```\n\u003e Avoid sending anonymous functions between remote nodes. Distributed BEAM nodes send function “closures” as a serialized object. For remote execution (e.g., `Node.spawn/2`), the function must be sent (serialized) over the network.\n \nThen, from the container node IEx shell, call the function remotely on the host node:\n\n```bash\niex(elixir_node@container)2\u003e Node.spawn(:\"host@host.docker.internal\", Greet, :say_hello, [])\n```\n\n\u003c/details\u003e\n\n## Inspecting and Using `epmd` in a Container \n\u003e This section explores how to inspect and interact with the **Erlang Port Mapper Daemon (epmd)** inside a running Elixir Docker container. This is useful for understanding how distributed Elixir nodes discover each other via `epmd`.\n\n\u003cdetails\u003e\n\n#### Start an Elixir Container\n\n```bash\nginsenglee@Ginsengs-MacBook-Air ~ % docker run -it --name nostalgic_banzai \\\n  --add-host host.docker.internal:host-gateway \\\n  elixir bash\n```\n\n#### Locate the `epmd` Binary\n\n```bash\nroot@e9e6d65de9af:/# which epmd \n/usr/local/bin/epmd\n```\n\n#### Manually Start `epmd`\n```\nroot@e9e6d65de9af:/# epmd -daemon \nroot@e9e6d65de9af:/# ps aux | grep epmd\n \nroot        19  0.0  0.0   2824   928 ?        S    06:46   0:00 epmd -daemon\n```\n\n#### Look Up Listening Ports\n```\nroot@e9e6d65de9af:/# netstat -tlnp | grep 4369 \ntcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      19/epmd             \ntcp6       0      0 :::4369                 :::*                    LISTEN      19/epmd             \n```\n\u003e This requires `net-tools` installed on the container. If not installed, run the command of `apt-get update \u0026\u0026 apt-get install net-tools ` to download the binary.\n\n#### Check for Registered Nodes\n\nInitially there will be no nodes:\n```\nroot@e9e6d65de9af:/# epmd -names\nepmd: up and running on port 4369 with data:\n```\n\n#### Open a Second Terminal in the Same Container\n```\nginsenglee@Ginsengs-MacBook-Air ~ % docker exec -it nostalgic_banzai bash \n```\n\nStart a named Elixir node: \n```\nroot@e9e6d65de9af:/# iex --name node_in_container_1@container --cookie my_cookie \n```\n\nYou should now see this node registered with `epmd` in the first container:\n\n```bash\nroot@e9e6d65de9af:/# epmd -names\nepmd: up and running on port 4369 with data:\nname node_in_container_1 at port 33911\n```\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcynicdog%2Felixir-in-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcynicdog%2Felixir-in-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcynicdog%2Felixir-in-container/lists"}