private static void OnContainerStopped(object sender, ContainerLifetimeEvent @event) { var container = @event.Container; _logger.WriteLine(LogLevel.Nfo, "Container {0} stopped", container.Id); StopProxy(container.Id); _runningProxies.Remove(container.Id); }
private static void OnContainerDetected(object sender, ContainerLifetimeEvent @event) { var container = @event.Container; _logger.WriteLine(LogLevel.Nfo, "Container {0} detected", container.Id); var proxy = new Process(); proxy.StartInfo = new ProcessStartInfo(_dockerProxyExePath, $"-container-ip {container.IpAddress} " + $"-container-port {container.PrivatePort} " + $"-host-port {container.PublicPort} " + "-proto tcp") { UseShellExecute = false, CreateNoWindow = true }; proxy.Start(); _runningProxies.Add(container.Id, proxy); _logger.WriteLine(LogLevel.Nfo, "Started proxy {0} on port localhost:{1}", container.Id, container.PublicPort); }