From 69ff7524238d1f7752ffadd655643e44954b5a55 Mon Sep 17 00:00:00 2001 From: xieguigang Date: Thu, 24 Jan 2019 11:36:03 +0800 Subject: [PATCH] add command wrapper --- Docker/Environment.vb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Docker/Environment.vb b/Docker/Environment.vb index f992978..743eceb 100644 --- a/Docker/Environment.vb +++ b/Docker/Environment.vb @@ -42,9 +42,9 @@ #End Region +Imports System.Runtime.CompilerServices Imports System.Text Imports Darwinism.Docker.Arguments -Imports Microsoft.VisualBasic.CommandLine.InteropService ''' ''' The container environment module for ``docker run ...`` @@ -216,9 +216,9 @@ Public Class Environment Const InvalidMount$ = "Shared Drive argument is presented, but value is invalid, -v option will be ignored!" ''' - ''' + ''' Create a docker run command for running command ``app arguments`` ''' - ''' + ''' ``app arguments`` ''' Working directory inside the container ''' Publish a container's port(s) to the host ''' @@ -243,3 +243,21 @@ Public Class Environment End Function End Class +Public Class DockerAppDriver + + ReadOnly docker As Environment + ReadOnly powershell As New PowerShell + ReadOnly appHome$ + ReadOnly appName$ + + Sub New(container As Image, app$, Optional mount As Mount = Nothing, Optional home$ = Nothing) + docker = New Environment(container).Mount([shared]:=mount) + appHome = home + appName = app + End Sub + + + Public Function Shell(args$, Optional workdir$ = Nothing) As String + Return powershell(docker.CreateDockerCommand($"{appHome}/{appName} {args}", workdir:=workdir)) + End Function +End Class \ No newline at end of file