Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dockerdiscovery external plugin #301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions content/explugins/dockerdiscovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
+++
title = "dockerdiscovery"
description = "*dockerdiscovery* - add/remove DNS records for Docker containers."
weight = 50
tags = [ "plugin" , "docker", "discovery", "containers" ]
categories = [ "plugin", "external" ]
date = "2023-11-01T09:10:00-03:00"
repo = "https://github.com/kevinjqiu/coredns-dockerdiscovery"
home = "https://github.com/kevinjqiu/coredns-dockerdiscovery/blob/master/README.md"
+++

## Description

Docker discovery plugin for CoreDNS.

## Syntax

docker [DOCKER_ENDPOINT] {
domain DOMAIN_NAME
hostname_domain HOSTNAME_DOMAIN_NAME
network_aliases DOCKER_NETWORK
label LABEL
compose_domain COMPOSE_DOMAIN_NAME
}

* `DOCKER_ENDPOINT`: the path to the docker socket. If unspecified, defaults to `unix:///var/run/docker.sock`. It can also be TCP socket, such as `tcp://127.0.0.1:999`.
* `DOMAIN_NAME`: the name of the domain for [container name](https://docs.docker.com/engine/reference/run/#name---name), e.g. when `DOMAIN_NAME` is `docker.loc`, your container with `my-nginx` (as subdomain) [name](https://docs.docker.com/engine/reference/run/#name---name) will be assigned the domain name: `my-nginx.docker.loc`
* `HOSTNAME_DOMAIN_NAME`: the name of the domain for [hostname](https://docs.docker.com/config/containers/container-networking/#ip-address-and-hostname). Work same as `DOMAIN_NAME` for hostname.
* `COMPOSE_DOMAIN_NAME`: the name of the domain when it is determined the
container is managed by docker-compose. e.g. for a compose project of
"internal" and service of "nginx", if `COMPOSE_DOMAIN_NAME` is
`compose.loc` the fqdn will be `nginx.internal.compose.loc`
* `DOCKER_NETWORK`: the name of the docker network. Resolve directly by [network aliases](https://docs.docker.com/v17.09/engine/userguide/networking/configure-dns) (like internal docker dns resolve host by aliases whole network)
* `LABEL`: container label of resolving host (by default enable and equals ```coredns.dockerdiscovery.host```)

## Examples

~~~ corefile
. {
docker unix:///var/run/docker.sock {
domain {$COREDNS_DOCKER_DOMAIN}
hostname_domain {$COREDNS_DOCKER_HOSTNAME_DOMAIN}
compose_domain {$COREDNS_DOCKER_COMPOSE_DOMAIN}

domain docker
hostname_domain docker
compose_domain docker

domain local
hostname_domain local
compose_domain local

ttl 30

network_aliases net1
network_aliases net2
}
}
~~~