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

Error on startup #2

Closed
GM-Alex opened this issue Dec 4, 2014 · 10 comments
Closed

Error on startup #2

GM-Alex opened this issue Dec 4, 2014 · 10 comments

Comments

@GM-Alex
Copy link

GM-Alex commented Dec 4, 2014

Hi Ben,

I'm getting the following error in the logs:

/opt/docker-dns/lib/docker-inspect.js:78 self.log.debug(self.name, "inspecting " + containers.length +" containers"); ^ TypeError: Cannot read property 'length' of null at /opt/docker-dns/lib/docker-inspect.js:78:55 at /opt/docker-dns/node_modules/dockerode/lib/docker.js:192:5 at Modem.buildPayload (/opt/docker-dns/node_modules/dockerode/node_modules/docker-modem/lib/modem.js:154:19) at ClientRequest.<anonymous> (/opt/docker-dns/node_modules/dockerode/node_modules/docker-modem/lib/modem.js:139:10) at ClientRequest.emit (events.js:95:17) at Socket.socketErrorListener (http.js:1551:9) at Socket.emit (events.js:95:17) at net.js:440:14 at process._tickCallback (node.js:419:13) [DD] info Loading config from /opt/docker-dns/config/config.js

My docker version is 1.3.2.

Greetings,
Alex

@bnfinet
Copy link
Owner

bnfinet commented Dec 4, 2014

Thanks for the report Alex,

How are you running docker-dns? Is it from the published docker container at https://registry.hub.docker.com/u/bfoote/docker-dns/ or is it from source here?

Could please you post your config file, your OS and in the case of the docker instance how you called docker run?

@GM-Alex
Copy link
Author

GM-Alex commented Dec 4, 2014

Hi,

my config looks the following:

var config = {};

config.development = true;
config.debug = false;

// a fake top level domain
// appended to all generated hostnames
config.faketld = "local";

// frequency of dns entry refresh from docker containers
config.pollinterval = 17 * 1000;

// multiple dockers can be configured
// each one should gets it's own namespace
// hostname.publicname.faketld
config.dockers  = [{
    // for 'publicly' exposed ports
    // when a service is offered on '0.0.0.0'
    // this is the IP lookups will return
    publicip: "10.20.0.100",

    // the public name is to give this docker instance it's own namespace
    publicname: "public.docker",

    // the local name is to provide a namespace for routing 172.17.0.0 addresses
    localname: "local.docker",

    // dockerode config
    // see: https://github.com/apocas/dockerode
    // and http://docs.docker.io/en/latest/use/basics/#bind-docker
    dockerode: {
            socketPath: '/var/run/docker.sock'
    }
}];

// node-named config
// see: https://github.com/trevoro/node-named
// bindip is for this container only, not docker-wide
config.node_named = {
    port: 53,
    bindip: '0.0.0.0'
};

module.exports = config;

I cloned the git repository form here (github) and used build_docker.sh (sudo ./build_docker.sh) and run_docker.sh (sudo ./run_docker.sh local config/config.js).

Edit: Os is Ubuntu 14.10 and I used the latest docker version from the docker repository not the Ubuntu one.

Greetings,
Alex

@bnfinet
Copy link
Owner

bnfinet commented Dec 4, 2014

I've just cloned a fresh copy, built a fresh container and run it using your config and it worked well for me.

Could you try
docker rmi bnfinet/docker-dns
and then
run_docker.sh
That should pull a fresh container from docker hub.

since self.D.listContainers is failing (a call into the dockerode package) my guess is that it can't talk to the docker local api.

Does /var/run/docker.sock exist?
Also, what OS/arch are your on? Ubuntu?

Cheers,

ben

Edit: just saw your edit wrt Ubuntu 14.10, thanks

@GM-Alex
Copy link
Author

GM-Alex commented Dec 4, 2014

I already tried that, but I have no bnfinet/docker-dns image, instead of that I have bfoote/docker-dns. /var/run/docker.sock exists.

@GM-Alex
Copy link
Author

GM-Alex commented Dec 4, 2014

I also tried just now

echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

and got a valid json response.

@GM-Alex
Copy link
Author

GM-Alex commented Dec 4, 2014

If I install it directly on the host with npm it seems to work. Very strange... seems that the /var/run/docker.sock is not mapped correctly to the container or something like that.

@GM-Alex
Copy link
Author

GM-Alex commented Dec 4, 2014

I saw the permissions for docker.sock had the permission srw-rw----. I change it to srw-rw-rw- but it didn't fixed it, but adding --privileged=true to

CMD="docker run -d -t --privileged=true -h ${HOST} --name docker-dns ${BINDARG} -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/log:/var/log/supervisor ${CONFARG} bfoote/docker-dns ";

at run_docker.sh solved it.

In addition docker.socks is owned by the group docker, but that should be the default.

@bnfinet
Copy link
Owner

bnfinet commented Dec 4, 2014

aha! nice find

I was about to ask you to run
docker run --rm -i -t --name docker-dns-test -v /var/run/docker.sock:/var/run/docker.sock bfoote/docker-dns /bin/bash

and then once at the bash prompt run

echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

I'll document that here in case anyone else comes along.
I'd be curious to know if --privileged is required if your user is part of the docker group.

usermod -a -G docker ${USER}

newgrp docker

Thanks!

@GM-Alex
Copy link
Author

GM-Alex commented Dec 12, 2014

I notice that there was one question left. Yes my user is part of the docker group.

@bnfinet
Copy link
Owner

bnfinet commented Dec 12, 2014

Thanks again Alex, closing this.

Please do let me know how it goes!

@bnfinet bnfinet closed this as completed Dec 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants