There are actually a few errors here. First container is not what you think it is. It is not the result of docker.containers.list(), it is a function.
Consider the following example
var hello = function(){
return "hello";
}
console.log(hello); // [Function]
console.log(hello()); // hello
hello is the function that returns "hello" but hello is not equal to "hello".
Basically when you are sending container, you aren't actually sending the result of docker.containers.list(), but the function itself.
Your second problem is that you are using an async function, but you are not waiting for the callback of this function to emit your data.
So basically with your current code, you are sending the wrong thing, at the wrong time.
What you need to do in order to make things work is probably something like this :
io.sockets.on( 'connection', function( socket ) {
docker.containers.list( function( err, res ) {
socket.emit( 'message', res );
});
});
Haven't tried it, but it should work!