title: Connect to remote Docker via Node.js
body: <p>I have Docker set up and running on one of my servers and can connect to it remotely like this:</p>
  
  <p><code>docker --tlsverify -H tcp://web2.webcom.dk:4243 images</code></p>
  
  <p>I used <a href="http://docs.docker.com/installation/ubuntulinux/#ubuntu-raring-1304-and-saucy-1310-64-bit" rel="nofollow">this</a> and <a href="http://sheerun.net/2014/05/17/remote-access-to-docker-with-tls/" rel="nofollow">this</a> to get it set up.</p>
  
  <p>What I would like to do is to be able to connect to it via Node.js and have tried doing so with <a href="https://github.com/apocas/dockerode" rel="nofollow">dockerode</a> which to me seems to be the best option.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>Docker = require 'dockerode'
  
  docker = new Docker
    host: 'tcp://web2.webcom.dk'
    port: 4243
    tls: true
    tlscacert: '/Users/jacob/.docker/ca.pem'
    tlscert: '/Users/jacob/.docker/cert.pem'
    tlskey: '/Users/jacob/.docker/key.pem'
    tlsverify: true
  
  container = docker.getContainer '826544226fdc'
  container.start (err, data) -&gt;
    return console.error err if err?
    console.log data
  </code></pre>
  
  <p>That doesn't work though, as I get this error:</p>
  
  <pre><code>{ [Error: connect ECONNREFUSED]
    code: 'ECONNREFUSED',
    errno: 'ECONNREFUSED',
    syscall: 'connect' }
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This works locally:</p>
  
  <pre><code>Docker = require 'dockerode'
  
  docker = new Docker
    host: '192.168.59.103'
    port: 2375
    socketPath: false
  
  docker.run 'ubuntu', ['bash', '-c', 'uname -a'], process.stdout, (err, data, container) -&gt;
    return console.error err if err?
  </code></pre>
  
  <p>But if I use my remote hosts IP and port I get this:</p>
  
  <pre><code>{ [Error: Parse Error] bytesParsed: 0, code: 'HPE_INVALID_CONSTANT' }
  </code></pre>
  
  <p>How can I connect to my remote host?</p>