microsoft/Docker-PowerShell

How do I start container on specific network?

artisticcheese opened this issue · 1 comments

Like below from EXE?


# Connect new container to the MyNatNetwork
C:\> docker run -it --network=MyNatNetwork <image> <cmd>

It's unfortunately convoluted at the moment, though at least possible. The field you need is NetworkMode on the Docker.DotNet.Models.HostConfig object, which you can pass to the -HostConfiguration parameter on New-Container.  To get a HostConfig object, you'll need to new one up using [Docker.DotNet.Models.HostConfig]::new() and then set the NetworkMode to whatever string you would have used in docker, like "MyNatNetwork" in your example above.