From 8d706dce855d185dd59dc84af4077593c1c3bbad Mon Sep 17 00:00:00 2001 From: Joshua Benjamin Date: Wed, 30 Aug 2017 13:33:51 -0700 Subject: [PATCH] Add port mappings (#13) Signed-off-by: Joshua Benjamin --- src/LclDckr/Commands/Run/RunArguments.cs | 11 +++++++++-- src/LclDckr/DockerClient.cs | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/LclDckr/Commands/Run/RunArguments.cs b/src/LclDckr/Commands/Run/RunArguments.cs index a906acc..7a1b4b5 100644 --- a/src/LclDckr/Commands/Run/RunArguments.cs +++ b/src/LclDckr/Commands/Run/RunArguments.cs @@ -11,9 +11,11 @@ public class RunArguments public string HostName { get; set; } - public IDictionary EnvironmentArgs = new Dictionary(); + public IDictionary EnvironmentArgs { get; set; } = new Dictionary(); - public IList Volumes = new List(); + public IList Volumes { get; set; } = new List(); + + public IDictionary PortMappings { get; set; } = new Dictionary(); public string ToArgString() { @@ -44,6 +46,11 @@ public string ToArgString() args.Append($" -v {volume}"); } + foreach (var mapping in PortMappings) + { + args.Append($" -p {mapping.Key}:{mapping.Value}"); + } + return args.ToString(); } } diff --git a/src/LclDckr/DockerClient.cs b/src/LclDckr/DockerClient.cs index a03baa9..a4ca7df 100644 --- a/src/LclDckr/DockerClient.cs +++ b/src/LclDckr/DockerClient.cs @@ -331,7 +331,8 @@ private Process GetDockerProcess(string arguments) Arguments = arguments, RedirectStandardOutput = true, RedirectStandardError = true, - UseShellExecute = false + UseShellExecute = false, + CreateNoWindow = true } }; }