title: How to communicate between Docker containers
body: <p>I am new to Docker and containerization methods in general so I may be just thinking about this wrong, but I am trying to setup a <strong>PowerShell as a Service</strong> type of application where a client can communicate to a powershell shell in 2 ways:</p>
  
  <ol>
  <li>A light-weight HTTP API</li>
  <li>An HTTP WebSocket</li>
  </ol>
  
  <p>According to what I have read, we want each service to be in its own container which means I think I need 2 different containers:</p>
  
  <ol>
  <li>One container would host PowerShell on Windows using the docker image <code>mcr.microsoft.com/powershell</code> and is pre-built with the AzureAD module for PowerShell.  </li>
  <li>The other container would host my API endpoint that is publicly available on some address like <code>http:localhost:8080</code>.</li>
  </ol>
  
  <p>I want to be able to run something like:</p>
  
  <pre><code>POST http://localhost:8080/powershell/command
  {
      "command": "Get-AzureADUser -ObjectId &lt;guid&gt;"
  }
  </code></pre>
  
  <p>Then I would <em>somehow</em> pipe that "command" through to the PowerShell instance running in the other container.  Where I get confused is how can this be done? As-is, the PowerShell hosted windows container doesn't expose any ports or any way to communicate with it. Its basically a black box that you can only interact with via something like <code>docker run -it &lt;image&gt;</code> right?  This command allows me to remote (is that the right term for it?) into the container and run commands in PowerShell.</p>
  
  <p>The only way I can think of doing this is to NOT use 2 containers and instead use a dotnet-mvc or node-windows image as my base, create a second image that includes the installation of powershell, and then finally use that second image to host the entirety of my application. Then, inside the .NET MVC or NodeJS application I would be responsible for forking a node psuedo-terminal using something like <code>node-pty</code>. And since my image already includes the AzureAD module from the dockerfile I should be able to just pipe commands through to the psuedo-terminal via stdin/stdout.</p>
  
  <p>I see this application as having 2 distinct services, so it feels "hacky" to use a single container, but if this is the only solution I guess thats what I have to do.</p>
  
  <p>Any guidance or tips on how I could accomplish this are welcome! 
  Thank you</p>