Could not find docker containers

I follow this guide to discover the service http://jasonwilder.com/blog/2014/07/15/docker-service-discovery

Short:

I created an etcd host running on xyzd: 4001

docker run -d --name etcd -p 4001:4001 -p 7001:7001 coreos/etcd 

A backend server has been created on which the container on backend_serverip is running: 8000 and docker-register

 $ docker run -d -p 8000:8000 --name whoami -t jwilder/whoami $ docker run --name docker-register -d -e HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}') -e ETCD_HOST=xyzd:4001 -v /var/run/docker.sock:/var/run/docker.sock -t jwilder/docker-register 

Another server server has been created on which the container on backend2_serverip is running: 8000 and docker-register

  $ docker run -d -p 8000:8000 --name whoami -t jwilder/whoami $ docker run --name docker-register -d -e HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}') -e ETCD_HOST=xyzd:4001 -v /var/run/docker.sock:/var/run/docker.sock -t jwilder/docker-register 

Created client working with docker-discovery and ubuntu image

 $ docker run -d --net host --name docker-discover -e ETCD_HOST=10.170.71.226:4001 -p 127.0.0.1:1936:1936 -t jwilder/docker-discover 

When I look at the logs to see if the containers are registered, I see the following error

 2015/07/09 19:28:00 error running notify command: python /tmp/register.py, exit status 1 2015/07/09 19:28:00 Traceback (most recent call last): File "/tmp/register.py", line 22, in <module> backends = client.read("/backends") File "/usr/local/lib/python2.7/dist-packages/etcd/client.py", line 347, in read self.key_endpoint + key, self._MGET, params=params, timeout=timeout) File "/usr/local/lib/python2.7/dist-packages/etcd/client.py", line 587, in api_execute return self._handle_server_response(response) File "/usr/local/lib/python2.7/dist-packages/etcd/client.py", line 603, in _handle_ser etcd.EtcdError.handle(**r) File "/usr/local/lib/python2.7/dist-packages/etcd/__init__.py", line 184, in handle raise exc(msg, payload) etcd.EtcdKeyNotFound: Key not found : /backends 

I tried to manually create this directory, I also tried to run containers with a privileged option, but no luck

+8
docker service-discovery registry etcd
source share
1 answer

The error you get is related to an error in the code . The problem is that /backends does not exist in your etcd directory. You can create it yourself manually by doing this:

 curl -L http://127.0.0.1:4001/v2/keys/backends -XPUT -d dir=true 

Once the directory exists in etcd, you will no longer get the error.

I created a query that fixes the error, and if you want to use a fixed code, you can create your own image:

 git clone git@github.com:rca/docker-register.git cd docker-register docker build -t docker-register . 

Then your docker registration team will look like this:

 $ docker run --name docker-register -d -e HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}') -e ETCD_HOST=xyzd:4001 -v /var/run/docker.sock:/var/run/docker.sock -t docker-register 

Note. I just removed jwilder/ from the image name in the command to use your local version.

+4
source share

All Articles