title: Access Docker API on Windows via Named Pipes
body: <p>According to the Docker for Windows <a href="https://docs.docker.com/docker-for-windows/faqs/#how-do-i-connect-to-the-remote-docker-engine-api" rel="nofollow noreferrer">FAQ</a>, " clients can connect to the Docker Engine through a named pipe: npipe:////./pipe/docker_engine"</p>
  
  <p>I have been trying to connect to the API via named pipes to no avail:</p>
  
  <pre><code>public class DockerNamedPipeTest
  {
      private const string PIPE_PATH = "docker_engine";
  
      public void Test()
      {
          using (NamedPipeClientStream pipeClient = 
              new NamedPipeClientStream(
                  ".", 
                  PIPE_PATH, 
                  PipeDirection.InOut, 
                  PipeOptions.WriteThrough, 
                  TokenImpersonationLevel.Impersonation))
          {
              pipeClient.Connect(30);                
              Send(pipeClient);
              Receive(pipeClient);
          }
      }
  
      public void Send(NamedPipeClientStream pipeClient)
      {
          if (pipeClient.IsConnected)
          {
              byte[] buffer = Encoding.UTF8.GetBytes("GET /containers/json");
              pipeClient.Write(buffer, 0, buffer.Length);
              pipeClient.WaitForPipeDrain();
              pipeClient.Flush();
          }
      }
  
      public void Receive(NamedPipeClientStream pipeClient)
      {
          string result = string.Empty;
  
          if (pipeClient.IsConnected &amp;&amp; pipeClient.CanRead)
          {
              do
              {                    
                  byte b = (byte)pipeClient.ReadByte();   //  &lt;-- Hangs here
                  result += Convert.ToChar(b).ToString();
              }
              while (!pipeClient.IsMessageComplete);
          }
  
          Console.WriteLine(result);
      }
  }
  </code></pre>
  
  <p>Can anyone tell me what I am doing wrong?</p>