SlideShare a Scribd company logo
Bootstrapping
containers with confd
Michael Richardson @m_richo
Who’s heard of
Common methods for
configuring containers
Common methods for
configuring containers
1. Environment variables
2. Data volumes
3. External Systems
1. Environment
variables
1. Environment
variables
docker run -d --hostname my-rabbit 
--name some-rabbit 
-e RABBITMQ_DEFAULT_USER=user 
-e RABBITMQ_DEFAULT_PASS=password 
-e RABBITMQ_DEFAULT_VHOST=my_vhost 
rabbitmq:3-management
1. Environment
variables
docker run -d --hostname my-rabbit 
--name some-rabbit 
-e RABBITMQ_DEFAULT_USER=user 
-e RABBITMQ_DEFAULT_PASS=password 
-e RABBITMQ_DEFAULT_VHOST=my_vhost 
rabbitmq:3-management
1. Environment
variables
• super easy to set
• Most applications are configured
by config files rather than env vars.
2. Data volumes
2. Data volumes
docker run -d 
--name some-nginx 
-v /some/nginx.conf:/etc/nginx/nginx.conf:ro
nginx
2. Data volumes
docker run -d 
--name some-nginx 
-v /some/nginx.conf:/etc/nginx/nginx.conf:ro
nginx
2. Data volumes
• easily pass any configuration files
from docker host to containers.
• Doesn’t scale too well
3. External Systems
3. External Systems
3. External Systems
• Strong feature list and benefits
• More complexity
What do I want?
What do I want?
Simple method to set
config files when
bootstrapping containers
What do I want?
Simple method to set
config files when
bootstrapping containers
Say hi to
confd
confd
Uses templates and data to render local
configuration files.
https://github.com/kelseyhightower/confd
confd
Source of data
• etcd
• consul
• dynamodb
• Redis
• Zookeeper
• environment variables
confd
Source of data
• etcd
• consul
• dynamodb
• Redis
• Zookeeper
• environment variables
Confd example
confd Nginx template
/etc/confd/templates/nginx.conf.tmpl
server {
server_name {{ getenv "proxy_domain" }};
location / {
proxy_pass http://{{ getenv "backend_host" }};
proxy_redirect off;
}
}
Confd example
confd Nginx config
/etc/confd/conf.d/nginx.conf.toml
[template]
src = "proxy.conf.tmpl”
dest = "/etc/nginx/conf.d/proxy.conf”
Confd example
$ export proxy_domain=mydomain
$ export backend_host=www.mricho.com
$ /usr/local/bin/confd -onetime -backend env
$ cat /etc/nginx/conf.d/proxy.conf
server {
server_name mydomain;
location / {
proxy_pass http://www.mricho.com;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Confd example
$ export proxy_domain=mydomain
$ export backend_host=www.mricho.com
$ /usr/local/bin/confd -onetime -backend env
$ cat /etc/nginx/conf.d/proxy.conf
server {
server_name mydomain;
location / {
proxy_pass http://www.mricho.com;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Confd appied to containers
Confd appied to containers
1. Install confd binary to docker images (Dockerfile)
2. Add confd templates and config to docker images (Dockerfile)
3. Create a bootstrap script for your container at runtime
Confd appied to containers
1. Install confd binary to docker images (Dockerfile)
2. Add confd templates and config to docker images (Dockerfile)
3. Create a bootstrap script for your container at runtime
#!/bin/bash
set -e
export proxy_domain=${proxy_domain:-$HOSTNAME}
test $backend_host
/usr/local/bin/confd -onetime -backend env
echo "Starting Nginx”
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf
Confd appied to containers
1. Install confd binary to docker images (Dockerfile)
2. Add confd templates and config to docker images (Dockerfile)
3. Create a bootstrap script for your container at runtime
4. Run a container
docker run -it -p 80:80 
-e proxy_domain=mydomain 
-e backend_host=www.mricho.com 
confd-test
More than ‘strings’
More than ‘strings’
upstream backend_hosts {
{{ $nodes := split (getenv "app_servers") ":" }}{{range $nodes}}
server {{.}};{{end}}
}
app_servers="myapp01.local:myapp02.local:myapp03.local:myapp04.local"
upstream backend_hosts {
server myapp01.local;
server myapp02.local;
server myapp03.local;
server myapp04.local;
}
confd
Configure container
config files at runtime with
environment variables
THANKS
Links
https://github.com/kelseyhightower/confd
http://www.mricho.com/confd-and-docker-separating-config-and-code-for-containers/
https://github.com/m-richo/docker-confd-example
Michael Richardson - @m_richo

More Related Content

PDF
Consul - service discovery and others
PPT
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
PDF
Wordpress y Docker, de desarrollo a produccion
PDF
Kubernetes 1.3 - Highlights
PDF
The top 5 Kubernetes metrics to monitor
PDF
Service discovery in Docker environments
PPTX
CoreOS Overview and Current Status
PDF
Consul and Complex Networks
Consul - service discovery and others
Running High Performance and Fault Tolerant Elasticsearch Clusters on Docker
Wordpress y Docker, de desarrollo a produccion
Kubernetes 1.3 - Highlights
The top 5 Kubernetes metrics to monitor
Service discovery in Docker environments
CoreOS Overview and Current Status
Consul and Complex Networks

What's hot (20)

PDF
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
PDF
From pets to cattle - powered by CoreOS, docker, Mesos & nginx
PDF
15 kubernetes failure points you should watch
ODP
Continuous Security
PDF
Ansible not only for Dummies
KEY
A language for the Internet: Why JavaScript and Node.js is right for Internet...
PDF
Docker Runtime Security
PPTX
Docker on openstack by OpenSource Consulting
PDF
Docker in production service discovery with consul - road to opscon 2015
PDF
Cloning Running Servers with Docker and CRIU by Ross Boucher
PDF
Failsafe Mechanism for Yahoo Homepage
PDF
Kubernetes: Beyond Baby Steps
PDF
Replacing Squid with ATS
PPTX
Docker cluster with swarm, consul, registrator and consul-template
PDF
Delivering Go.CD with Terraform and Docker
PDF
Hacking on OpenStack\'s Nova source code
PPTX
Introduction to apache zoo keeper
PDF
Enhancing OpenShift Security for Business Critical Deployments
PDF
Docker Security in Production Overview
PDF
Web scale infrastructures with kubernetes and flannel
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
From pets to cattle - powered by CoreOS, docker, Mesos & nginx
15 kubernetes failure points you should watch
Continuous Security
Ansible not only for Dummies
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Docker Runtime Security
Docker on openstack by OpenSource Consulting
Docker in production service discovery with consul - road to opscon 2015
Cloning Running Servers with Docker and CRIU by Ross Boucher
Failsafe Mechanism for Yahoo Homepage
Kubernetes: Beyond Baby Steps
Replacing Squid with ATS
Docker cluster with swarm, consul, registrator and consul-template
Delivering Go.CD with Terraform and Docker
Hacking on OpenStack\'s Nova source code
Introduction to apache zoo keeper
Enhancing OpenShift Security for Business Critical Deployments
Docker Security in Production Overview
Web scale infrastructures with kubernetes and flannel
Ad

Similar to bootstrapping containers with confd (20)

PPTX
Running Docker in Development & Production (#ndcoslo 2015)
PDF
WP migrations
PDF
Nginx + PHP
DOC
X64服务器 lnmp服务器部署标准 new
PDF
PDF
Vagrant for real codemotion (moar tips! ;-))
KEY
Write php deploy everywhere
PDF
WordPress Security - ওয়ার্ডপ্রেসের সিকিউরিটি
DOCX
Vagrant file samples for various Hadoop distributions
PDF
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PDF
Challenges of container configuration
PDF
Facebook的缓存系统
PDF
4069180 Caching Performance Lessons From Facebook
PDF
Integration of neutron, nova and designate how to use it and how to configur...
PPTX
Drupal Deployment Troubles and Problems
PPTX
Dc kyiv2010 jun_08
PDF
Weird proxies/2 and a bit of magic
PDF
Securing Prometheus exporters using HashiCorp Vault
PDF
Fluentd intro at Tajo seoul meetup
ODP
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Running Docker in Development & Production (#ndcoslo 2015)
WP migrations
Nginx + PHP
X64服务器 lnmp服务器部署标准 new
Vagrant for real codemotion (moar tips! ;-))
Write php deploy everywhere
WordPress Security - ওয়ার্ডপ্রেসের সিকিউরিটি
Vagrant file samples for various Hadoop distributions
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
Challenges of container configuration
Facebook的缓存系统
4069180 Caching Performance Lessons From Facebook
Integration of neutron, nova and designate how to use it and how to configur...
Drupal Deployment Troubles and Problems
Dc kyiv2010 jun_08
Weird proxies/2 and a bit of magic
Securing Prometheus exporters using HashiCorp Vault
Fluentd intro at Tajo seoul meetup
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Ad

More from m_richardson (10)

PPTX
Persistence in the cloud with bosh
PPTX
Docker Service Registration and Discovery
PPTX
Puppetcamp Melbourne - puppetdb
PPTX
Node collaboration - sharing information between your systems
PPTX
Node collaboration - Exported Resources and PuppetDB
PPTX
Serverspec and Sensu - Testing and Monitoring collide
PPTX
Cooking with Chef
PPT
System Availability Talk
PPT
Chef - managing yours servers with Code
PPTX
Open Source Monitoring Tools
Persistence in the cloud with bosh
Docker Service Registration and Discovery
Puppetcamp Melbourne - puppetdb
Node collaboration - sharing information between your systems
Node collaboration - Exported Resources and PuppetDB
Serverspec and Sensu - Testing and Monitoring collide
Cooking with Chef
System Availability Talk
Chef - managing yours servers with Code
Open Source Monitoring Tools

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation theory and applications.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPT
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Modernizing your data center with Dell and AMD
Encapsulation theory and applications.pdf
Big Data Technologies - Introduction.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
The AUB Centre for AI in Media Proposal.docx
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Teaching material agriculture food technology

bootstrapping containers with confd

Editor's Notes

  • #32: Split function in golang’s string package
  • #33: Split function in golang’s string package