Skip to content

Instantly share code, notes, and snippets.

@dontpaniclabsgists
Created October 23, 2017 14:35
Show Gist options
  • Save dontpaniclabsgists/41a6d46025321526fd220cd4d9940c6d to your computer and use it in GitHub Desktop.
Save dontpaniclabsgists/41a6d46025321526fd220cd4d9940c6d to your computer and use it in GitHub Desktop.
securing_docker_14
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