Skip to content

Instantly share code, notes, and snippets.

@JayH5
Last active April 24, 2018 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayH5/d86f7c57b77f531e0340214f19c500fe to your computer and use it in GitHub Desktop.
Save JayH5/d86f7c57b77f531e0340214f19c500fe to your computer and use it in GitHub Desktop.
Elixir example: Marathon networking mode
# Marathon 1.5+: there is a `networks` field
# Networking modes can't be mixed so using the first one is fine
def networking_mode(%{"networks" => [network | _]} = _app_json),
do: network |> Map.get("mode", "container") |> String.to_existing_atom()
# Pre-Marathon 1.5 Docker container networking mode
def networking_mode(%{"container" => %{"docker" => %{"network" => "USER"}}}),
do: :container
def networking_mode(%{"container" => %{"docker" => %{"network" => "BRIDGE"}}}),
do: :"container/bridge"
# Otherwise, give up and default to host networking mode
def networking_mode(_), do: :host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment