Created
October 23, 2017 14:35
-
-
Save dontpaniclabsgists/41a6d46025321526fd220cd4d9940c6d to your computer and use it in GitHub Desktop.
securing_docker_14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Docker.DotNet; | |
using Docker.DotNet.Models; | |
using Docker.DotNet.X509; | |
using System; | |
using System.Net; | |
using System.Security.Cryptography.X509Certificates; | |
namespace ContainerLauncher | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true; | |
var credentials = new CertificateCredentials(new X509Certificate2(@"C:\path\to\my\cert\key.pfx", "test")); | |
DockerClient client = new DockerClientConfiguration(new Uri("tcp://smurtaugh-win10.ng.com:2376"), credentials).CreateClient(); | |
var containerId = client.Containers.CreateContainerAsync(new CreateContainerParameters() | |
{ | |
Image = "myImage", | |
Entrypoint = new[] { "some.exe", "1" } | |
}).Result.ID; | |
var startResult = client.Containers.StartContainerAsync(containerId, new ContainerStartParameters()).Result; | |
Console.WriteLine(startResult); | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment