title: How to enable docker API to access via http
body: <p>I'm trying to manage docker via PHP curl requests. (Using Ubuntu 15.10)</p>
  <p>I have followed API documentation but it bit confusing and also followed a few online tutorials but no luck.</p>
  <p>This is what I have done so far,
  stopped docker daemon and added</p>
  <pre><code>script
      /usr/bin/docker -H tcp://127.0.0.1:4243 -d
  end script
  </code></pre>
  <p>to</p>
  <pre><code>/etc/init/docker.conf
  </code></pre>
  <p>Docker daemon started</p>
  <p>This is My PHP script</p>
  <pre><code>function post_to_url($url, $data, $headers) {
      $ch = curl_init();
  
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
      curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
  
      curl_setopt($ch, CURLOPT_URL, $url);
      if ($headers != '') {
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      }
      curl_setopt($ch, CURLOPT_POST, 1);
      if ($data != '') {
          curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
      }
  
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
      $return = curl_exec($ch);
      if ($return == '') {
          return curl_getinfo($ch, CURLINFO_HTTP_CODE);
      } else {
          return $return;
      }
      curl_close($ch);
  }
  //Sample API request
  echo post_to_url('http://127.0.0.1:4243/containers/json', '', '');
  </code></pre>
  <p>But I did not able to get any output via CURL request?</p>
  <p>What I'm missing here?</p>