Skip to content

Instantly share code, notes, and snippets.

@danehans
Created October 27, 2014 22:14
Show Gist options
  • Save danehans/e52d0a67500121af510c to your computer and use it in GitHub Desktop.
Save danehans/e52d0a67500121af510c to your computer and use it in GitHub Desktop.
docker-spotter use case
Use Case:
Have docker-spotter look at events from the docker daemon to issue a pipework command. The events of interest are create/stop/restart/destroy container xyz. The pipework command creates a veth on a linux bridge named kbr-ex and attaches the other side of the veth (i.e. eth1) to the container. Since the container's eth1 interface is being used to bridge traffic, it does not use an IP address and therefore 0/0 is provided in the pipework command:
# /usr/bin/docker-spotter -e nova-network:start,restart:pipework:kbr-ex:{{.ID}}:0/0 -e nova-network:stop:echo:gone
This solution works very well when using a known name for a container.
The Challenge:
Kubernetes is being used to manage Docker containers. Kubernetes appends a hash to the Docker container name. Therefore, trying to use docker-spotter to match a specific name is not possible.
The Request:
Make docker-spotter capable of being more flexible in matching container creteria. Below are a few examples that will work for the use case:
1. Make docker-spotter capable of matching based on a regex string. Example- match all containers with a name that includes nova-network.
2. Make docker-spotter capable of matching based on the container Hostname parameter.
3. Make docker-spotter capable of matching based on a supplied ENV variable: https://docs.docker.com/reference/builder/#env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment