From d1e3a4bd8eaa97f5c03dad211d1ea8e2b5da65d7 Mon Sep 17 00:00:00 2001 From: xieguigang Date: Wed, 23 Jan 2019 13:41:27 +0800 Subject: [PATCH] shared drive mount test success --- Docker/Commands.vb | 8 +++++++- Docker/Image.vb | 2 +- Docker/PowerShell.vb | 4 ++++ Docker/test/Module1.vb | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Docker/Commands.vb b/Docker/Commands.vb index dd4fafa..9a6ac1c 100644 --- a/Docker/Commands.vb +++ b/Docker/Commands.vb @@ -86,6 +86,12 @@ Public Module Commands ReadOnly powershell As New PowerShell + Public Iterator Function CommandHistory() As IEnumerable(Of String) + For Each line As String In powershell.logs + Yield line + Next + End Function + ''' ''' Search the Docker Hub for images ''' @@ -141,7 +147,7 @@ Public Module Commands Dim options As New StringBuilder If Not mount Is Nothing Then - Call options.AppendLine(mount.ToString) + Call options.AppendLine($"-v {mount}") End If Return powershell($"docker run {options} {container} {command}") diff --git a/Docker/Image.vb b/Docker/Image.vb index eb61323..e1858dd 100644 --- a/Docker/Image.vb +++ b/Docker/Image.vb @@ -66,6 +66,6 @@ Public Class Mount ''' ''' Public Overrides Function ToString() As String - Return $"{local}:{virtual}" + Return $"{local.GetDirectoryFullPath}:{virtual}" End Function End Class \ No newline at end of file diff --git a/Docker/PowerShell.vb b/Docker/PowerShell.vb index fd2df19..53caaf8 100644 --- a/Docker/PowerShell.vb +++ b/Docker/PowerShell.vb @@ -9,6 +9,8 @@ Imports System.Text ''' Public Class PowerShell + Friend ReadOnly logs As New List(Of String) + ''' ''' ''' @@ -40,6 +42,8 @@ Public Class PowerShell out.AppendLine(obj.ToString()) Next + Call logs.Add(scriptText) + ' return the results of the script that has ' now been converted to text Return out.ToString() diff --git a/Docker/test/Module1.vb b/Docker/test/Module1.vb index d0c6541..2de1d00 100644 --- a/Docker/test/Module1.vb +++ b/Docker/test/Module1.vb @@ -14,6 +14,11 @@ Module Module1 Call Console.WriteLine(Docker.Run("centos", "echo ""hello world""")) + Call Console.WriteLine(Docker.Run("centos", "ls -l /mnt/ntfs", New Docker.Mount With {.local = "D:\test", .virtual = "/mnt/ntfs"})) + + For Each line In Docker.CommandHistory + Call Console.WriteLine(line) + Next Pause() End Sub