title: WCF inside Docker container using message security and client credential type "Windows"
body: <p>I'm trying to run a WCF service inside a docker container using a binding  with security mode <code>message</code> and client credential type <code>Windows</code>. Something like:</p>
  
  <pre><code>...
  &lt;bindings&gt;
    &lt;wsHttpBinding&gt;
      &lt;binding name="wsHttpBinding_IService1"&gt;
        &lt;security mode="Message"&gt;
          &lt;message clientCredentialType="Windows"/&gt;
        &lt;/security&gt;
      &lt;/binding&gt;   
    &lt;/wsHttpBinding&gt;
  &lt;/bindings&gt;
  ...
  </code></pre>
  
  <p>I have successfully created and started the container and, thanks to gMSA and a tutorial found <a href="https://blogs.msdn.microsoft.com/containerstuff/2017/01/30/create-a-container-with-active-directory-support/" rel="nofollow noreferrer">here</a>, I can issue SQL commands against a SQL Server 2016 using Windows Authentication from within the service inside the container. </p>
  
  <p>So far so good, but when connecting to the service inside the container with a client running on the docker host machine, I am greeted with the error message:</p>
  
  <pre>
  System.ServiceModel.Security.SecurityNegotiationException: 
  The server has rejected the client credentials
  </pre>
  
  <p>To my understanding this is happening, because the docker container is using its host name (which, after checking it with <code>docker exec</code>, appears to be some hash value) to ask the domain controller for valid credentials. Since the container isn't part of the domain (even if it thinks it is thanks to the gMSA) the domain controller denies the request, and the client receives the aforementioned message.</p>
  
  <p>So my questions are: Is this really what's happening, or did I miss something? Is there any way to make windows authentication work with the above binding or is my approach conceptually flawed? Maybe there is another way to make Windows authentication with WCF inside docker possible?</p>
  
  <p>I couldn't find any threads about my problem, except for <a href="https://stackoverflow.com/questions/48544367/windows-container-with-legacy-wcf-tcp-issue">this one</a> which didn't receive any answers. So any help would be much appreciated.</p>