Docker.Names

Summary

api(name)

Ensures a name is prefixed with a “/“ for matching against Docker’s API

container_safe(name)

Sanitizes a name for use with Docker. Docker doesn’t support / in names, so convert them to underscores

extract_tag(image)

Returns the tag of a Docker image given its name

split_image(image)

Divides an image name into a tuple of {registry, repo, image}

Functions

api(name)

Ensures a name is prefixed with a “/“ for matching against Docker’s API.

container_safe(name)

Sanitizes a name for use with Docker. Docker doesn’t support / in names, so convert them to underscores.

Examples

iex> Docker.Names.container_safe("foo")
"foo"

iex> Docker.Names.container_safe("foo/bar/bacon")
"foo_bar_bacon"

iex> Docker.Names.container_safe("foo_bar")
"foo_bar"
extract_tag(image)

Returns the tag of a Docker image given its name.

Examples

iex> Docker.Names.extract_tag("foo")
"latest"

iex > Docker.Names.extract_tag("foo:bar")
"bar"

iex > Docker.Names.extract_tag("foo/bar:bacon")
"bacon"
split_image(image)

Divides an image name into a tuple of {registry, repo, image}.

Examples

iex> Docker.Names.split_image("quay.io/wildcard/rabbitmq")
{"quay.io", "wildcard", "rabbitmq"}

iex> Docker.Names.split_image("dockerfile/rabbitmq")
{"index.docker.io", "dockerfile", "rabbitmq"}

iex> Docker.Names.split_image("ubuntu")
{"index.docker.io", "_", "ubuntu"}