Skip to content

Instantly share code, notes, and snippets.

@melito
Forked from philips/gist:6458572
Created March 21, 2014 05:40
Show Gist options
  • Save melito/9680190 to your computer and use it in GitHub Desktop.
Save melito/9680190 to your computer and use it in GitHub Desktop.

This is a temporary workaround to have etcd listening on all interfaces so you can access it from docker containers.

Add a local etcd unit file

Create a file called /media/state/units/etcd-local.service that has the following contents:

[Unit]
Description=etcd local

[Service]
User=etcd
PermissionsStartOnly=true
ExecStartPre=/bin/systemctl kill etcd.service
ExecStartPre=/usr/bin/etcd-pre-exec
ExecStart=/usr/bin/etcd -d /var/lib/etcd -f -cl 0.0.0.0

Restart=always
# Set a longish timeout in case this machine isn't behaving
# nicely and bothering the rest of the cluster
RestartSec=10s

[Install]
WantedBy=local.target

Enable the local etcd

sudo systemctl restart local-enable.service

curl etcd from inside a container

Setup an ubuntu container with curl

$ docker run -t -i ubuntu /bin/bash
$ apt-get install curl

Now you need to find the ip of the bridge

$ ip route
default via 172.17.42.1 dev eth0
172.17.0.0/16 dev eth0  proto kernel  scope link  src 172.17.0.2

Now just curl from the default route IP:

$ curl http://172.17.42.1:4001/v1/keys/

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment