microsoft / docker-powershell Goto Github PK
View Code? Open in Web Editor NEWPowerShell Module for Docker
License: MIT License
PowerShell Module for Docker
License: MIT License
We are missing a key scenario: tagging images. We should support that.
The module needs help files for cmdlet and parameter descriptions and examples.
Right now, all exceptions from Docker.DotNet are just bubbled up to the PowerShell session, leading to some less than clear error messages (eg: Get-Container with no target daemon fails with "An error occurred while sending the request"). Some of these may require updates to Docker.DotNet to throw more specific errors, but in general the friendly error messages (with appropriate guidance) should be generated in the Docker.PowerShell code.
The "container" is implied
Output of $PSVersionTable
(from a powershell process):
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.14931.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14931.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Output of ipmo Docker; (module Docker).Version.ToString()
(from a powershell process):
ipmo Docker; (module Docker).Version.ToString()
0.1.0.100
(paste your output here)
Steps to reproduce the issue:
1.
docker create alpine ash
d2fc2b6997b25d3d4647bdc0435dd1459c37a203a7a9e01f2bd9d8d3192c302a
Copy-ContainerFile -Id d2fc2b6997b25d3d4647bdc0435dd1459c37a203a7a9e01f2bd9d8d3192c302a -Path /lib -Destination .\hestsmed
Copy-ContainerFile : Attempted to read past the end of the stream.
At line:1 char:1
+ Copy-ContainerFile -Id d2fc2b6997b25d3d4647bdc0435dd1459c37a203a7a9e0 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-ContainerFile], EndOfStreamException
+ FullyQualifiedErrorId : Docker Client Exception,Docker.PowerShell.Cmdlets.CopyContainerFile
What actually happened?:
Error
What did you expect to happen?:
File copied
Steps to reproduce the issue:
What actually happened?:
Error being thrown
container 7c4de1fc1a26875e307a094f98d5c510750b30a0c29a013c79f6001a454c3f35 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"ApplicationName":"","CommandLine":"\"powershell (dir c:\\)\"","User":"","WorkingDirectory":"C:\\","Environment":{},"EmulateConsole":false,"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}
What did you expect to happen?:
Same as output of
docker exec 7c "powershell.exe" "(dir c:\)"
That is listing of directory on C drive
Additional information:
I put a Dockerfile in the current directory and tried Build-ContainerImage.
> Build-ContainerImage
Build-ContainerImage : Docker API responded with status code=InternalServerError, response=
At line:1 char:1
+ Build-ContainerImage
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-ContainerImage], DockerApiException
+ FullyQualifiedErrorId : Docker.DotNet.DockerApiException,Docker.PowerShell.Cmdlets.NewContainerImage
This looks terrible:
> get-containerimage
ID : sha256:4aa830bd8559eb7e62bf7377f9fe25733df447bd03acdc3d8c80aa9c9668f2f9
ParentID :
RepoTags : {windowsservercore:10.0.14331.1001, windowsservercore:latest}
RepoDigests :
Created : 4/26/2016 1:06:21 AM
Size : 6871257275
VirtualSize : 6871257275
Labels :
ID : sha256:5f7e056d4b596e6bd55fa476c619ca4e267cf314dd1f659603b60ab6e7f7eb7f
ParentID :
RepoTags : {nanoserver:10.0.14331.1001, nanoserver:latest}
RepoDigests :
Created : 4/24/2016 4:21:37 PM
Size : 648232531
VirtualSize : 648232531
Labels :
ID : sha256:865c740600feed63598d91f143954df263c1a86df8e018a568143c47143ceae9
ParentID :
RepoTags : {oldwin:latest}
RepoDigests :
Created : 4/24/2016 4:19:17 PM
Size : 5913444191
VirtualSize : 5913444191
Labels :
I get this error:
> Install-Module Docker -Repository DockerPS-Dev
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'DockerPS-Dev'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
WARNING: Could not get response from query
'https://ci.appveyor.com/nuget/docker-powershell-dev/package/Docker/0.0.0.35'.
WARNING: MSG:SourceLocationNotValid «https://ci.appveyor.com/nuget/docker-powershell-dev/»
PackageManagement\Install-Package : Package 'Docker' failed to install.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1431 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (C:\Users\hillr\...er\Docker.nupkg:String) [Install-Package], Excep
tion
+ FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
kage
These three cmdlets are missing help content. Empty markdown files will be checked in as part of an upcoming change, but we need to get the actual content filled in soon.
Get-Container gives me this error:
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
what I tried:
install-Package Newtonsoft.Json -> same error
'cause there is no mention that this is pre-release anywhere in the readme. Should probably add that.
I just want to use "nanoserver" - don't demand an object please
I know Containers on win10 are still early preview but I wanted to test anyway.
Unfortunately there are currently no Container Images available for Win10.
When trying to create a container with the WindowsServerCore image, Docker run responds with an exception. New-Container does not and leaves an impression it worked correctly.
The current set of cmdlet names causes an error when importing the module due to name verification. While this can be suppressed by using the DisableNameChecking flag in Import-Module, the module really should adhere to valid PowerShell verbs. Alternates can be configured via aliases, which are not verified by Import-Module.
Currently I need to instantiate an AuthConfig object myself and then specify username and password.
$DockerAuth = [Docker.DotNet.Models.AuthConfig]::new()
$DockerAuth.Username = 'bgelens'
$DockerAuth.Password = 'mypassword'
Normally in the PowerShell world, there would be a wrapper cmdlet which would instantiate the object for me. Cmdlets are easier to discover for most users.
The class has no constructors. It would be nicer (in the current context) to have a constructor so we can pass in a pscredential or username and password during instantiation.
All cmdlets use -Id to mean name or ID, and we should have get-container and get-containerimage be consistent with that.
This replaces #87.
All PowerShell commands should have a singular noun.
Therefore, Get-ContainerDetails is in violation of this rule. To correct this, rename Get-ContainerDetails as Get-ContainerDetail, Get-ContainerInfo, or something similar.
If you're worried about backward compatibility with the Get-ContainerDetails name already, create a Get-ContainerDetails alias in the binary module itself or in a script module file and associate that alias with the new command name. I think this is early enough that you shouldn't be too worried about backward compatibility for this command, especially since another issue is logged against it saying it is not working.
Output of $PSVersionTable
(from a powershell process):
PS /Users/<username>/.local/share/powershell/Modules> $PSVersionTable.PSVersion
Major Minor Patch Label
----- ----- ----- -----
6 0 0 alpha
Output of ipmo Docker; (module Docker).Version.ToString()
(from a powershell process):
(paste your output here)
Steps to reproduce the issue:
What actually happened?:
I am on a MacOS system 10.11.6 and have installed the PowerShell from here: https://github.com/PowerShell/PowerShell
After that I tried installing the docker module, with the complete error:
PS /Users//.local/share/powershell/Modules> Install-Module Docker -Repository DockerPS-Dev
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by
running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'DockerPS-Dev'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PackageManagement\Install-Package : Could not compare "6.0.0-alpha" to "5.0". Error: "Cannot convert value "5.0" to type "System.Management.Automation.SemanticVersion". Error: "Cannot process argument because the value of argument "version" is not valid. Change the value of the "version" argument and run the operation again."" At /usr/local/microsoft/powershell/6.0.0-alpha.9/Modules/PowerShellGet/PSModule.psm1:1706 char:21oooooooooooooooooooooooooooooooooooo] + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : ComparisonFailure,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
What did you expect to happen?:
Successful Installation
Additional information:
Can't figure this one out...
It is not clear if the module already knows about a container host.
Therefore it may be best to show how to defined or set the host.
I was getting the error below after running Get-ContainerNetwork
PS C:\> Get-ContainerNetwork
Get-ContainerNetwork : The operation has timed out.
At line:1 char:1
+ Get-ContainerNetwork
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-ContainerNetwork], TimeoutException
+ FullyQualifiedErrorId : System.TimeoutException,Docker.PowerShell.Cmdlets.GetContainerNetwork
After following the instruction
https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start_configure_host, I was able to get passed the error. Maybe that error could also be friendlier or explicit.
Output of $PSVersionTable
(from a powershell process):
Name Value
---- -----
PSVersion 5.1.14393.206
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.206
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Output of ipmo Docker; (module Docker).Version.ToString()
(from a powershell process):
Name Version
---- -------
Docker 0.1.0.95
Docker 0.0.0.70
Docker 0.0.0.58
Steps to reproduce the issue:
README.md
Install-PackageProvider ContainerImage -Force
from this articleWhat actually happened?:
PS C:\windows\system32> Install-PackageProvider ContainerImage -Force
Install-PackageProvider : A command with name 'Save-ContainerImage' is already available on this system. This module
'ContainerImage' may override the existing commands. If you still want to install this module 'ContainerImage', use
-AllowClobber parameter.
At line:1 char:1
+ Install-PackageProvider ContainerImage -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pa
ckageProvider], Exception
+ FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack
ageManagement.Cmdlets.InstallPackageProvider
What did you expect to happen?:
The ContainerImage
Package Provider should install successfully, side by side with the Docker PowerShell module.
Additional information:
Cheers,
Trevor Sullivan
Docker Captain
Microsoft MVP: Cloud & Data Center Management
https://trevorsullivan.net
https://twitter.com/pcgeek86
Objects are for chumps
With the recent addition of -Id and -Name to Get-Container we need the same functionality in Get-ContainerImage
Output of $PSVersionTable
(from a powershell process):
Name Value
---- -----
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.11
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Output of ipmo Docker; (module Docker).Version.ToString()
(from a powershell process):
Wasn't able to Import Docker module yet due to Register-PSRespository cmdlet failure
Steps to reproduce the issue:
+ CategoryInfo : InvalidArgument: (https://ci.appv...-powershell-
dev:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository
What actually happened?:
Register-PSRepository : The specified Uri
'https://ci.appveyor.com/nuget/docker-powershell-dev' for parameter
'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web
Uri requirements.
At line:1 char:1
+ CategoryInfo : InvalidArgument: (https://ci.appv...-powershell-
dev:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository
What did you expect to happen?:
Register should be successful
Additional information:
The issue occurred on Debian distro
Linux kali 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux
New-ContainerNetwork names appear to be case-sensitive. Is that a Docker thing or should this be made case-insensitive more in keeping with PowerShell?
Like below from EXE?
# Connect new container to the MyNatNetwork
C:\> docker run -it --network=MyNatNetwork <image> <cmd>
With docker CLI, DOCKER_CERT_PATH specifies the cert path, but the user still has to specify --tls or --tlsverify or set DOCKER_TLS_VERIFY to turn on TLS.
Probably we should actually make sure we are implementing the verification side (I think we are not) and support DOCKER_TLS_VERIFY.
It would be handy if changes to the master or dev branches kicked off a pipeline to provide:
This might make it easier for IT folks like myself to pull down the latest version for testing purposes : )
Cheers!
I don't see an option to specify which registry you are pulling images from. Please add this option.
PS C:\Users\jostarks\Source\Repos\Docker-PowerShell> Get-ContainerDetails cranky_shaw
Get-ContainerDetails : Error converting value {null} to type 'System.Int64'. Path 'HostConfig.MemorySwappiness', line 1, position 1600.
At line:1 char:1
- CategoryInfo : NotSpecified: (:) [Get-ContainerDetails], JsonSerializationException
- FullyQualifiedErrorId : Newtonsoft.Json.JsonSerializationException,Docker.PowerShell.Cmdlets.GetContainerDetails
Build-ContainerImage unconditionally appends the provided path with the current powershell user's working directory, but that should only happen for relative paths. Absolute paths should be used directly.
The submodule for Docker.DotNet uses a separate fork instead of the master branch from https://github.com/ahmetalpbalkan/Docker.DotNet/. The changes in this fork should be PR'ed back into the master branch so that Docker.PowerShell is using the same Docker.DotNet code as everything else.
For some reason the HostAddress parameter is only present on the default parameter set... I think this was a hold-over from an older design where the objects would track their host address, but that is no longer the case. HostAddress should be present on every parameter set. Updating this will also require an update to the help content for all cmdlets.
Output of $PSVersionTable
(from a powershell process):
Name Value
---- -----
PSVersion 5.1.14393.206
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.206
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Output of ipmo Docker; (module Docker).Version.ToString()
(from a powershell process):
PS C:\WINDOWS\system32> (get-module docker).Version
Major Minor Build Revision
----- ----- ----- --------
0 1 0 111
Steps to reproduce the issue:
1.
Import-module docker
$config = [Docker.DotNet.Models.Config]::new()
$dict = new-object 'system.collections.generic.dictionary[string,object]'
$dict.Add("d:\container\content", "c:\inetpub\wwwrooot\content")
$config.Volumes = $dict
Run-ContainerImage -ImageIdOrName "microsoft/iis" -Configuration $config -Detach
Run-ContainerImage : Docker API responded with status code=InternalServerError, response=json: cannot unmarshal string into Go value of type struct {}
At D:\docker\run-MFEcountainer.ps1:13 char:1
+ Run-ContainerImage -ImageIdOrName "microsoft/iis" -Configuration $con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-ContainerImage], DockerApiException
+ FullyQualifiedErrorId : Docker Client Exception,Docker.PowerShell.Cmdlets.InvokeContainerImage
What actually happened?:
Error
What did you expect to happen?:
Start container
Additional information:
When using any of the cmdlets that provide an interactive session with the container (Enter-ContainerSession, Run-ContainerImage, Exec-Container), the resulting session will work fine when connected to the daemon by tcp or unix socket, but fails to accept input and hangs when connected via named pipe. Still not sure why, investigation ongoing...
In the latest Win10 build 14379, the inbox Containers module got removed and with it, the Install-ContainerOSImage function. The ContainerImage Package Provider relies on this function to install the base OS image but now it is missing, we cannot install the base image anymore.
I get that we need to switch working with Docker API and this module but now I can't start anymore until Install-ContainerOSImage is replaced or the Package Provider installs the image in another way.
makes things so much easier... :)
a more "speaking" package name would be fine
Steps to reproduce the issue:
1.
New-Container -Isolation HyperV -Name "first" -Command @("dsadasd", "") -ImageIdOrName "microsoft/iis"
2.
3.
What actually happened?:
Getting error
New-Container : Cannot validate argument on parameter 'Command'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At line:1 char:56
+ ... ner -Isolation HyperV -Name "first" -Command @("dsadasd", "") -ImageI ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [New-Container], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Docker.PowerShell.Cmdlets.NewContainer
What did you expect to happen?:
Supposed to take empty values (like if you used Get-Content to pull contents of text file with empty lines)
Additional information:
Also what is supposed to be fed to -Command? Is it commands from docker file or it can be plainly written powershell script?
Get-Container | Attach-Container
Attach-Container : The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
+ CategoryInfo : NotSpecified: (:) [Enter-ContainerSession], COMException
+ FullyQualifiedErrorId : Docker Client Exception,Docker.PowerShell.Cmdlets.EnterContainerSession
same with Enter-ContainerSession
reproduce:
PS remote to nanoserver VM, run detached container, try to enter with commands above.
when doing the same with docker attach, I get an error that TTY is not supported.
I was told by @PatrickLang in the MSDN Container Docs Repo that it should work with Docker PS
For consistency with other cmdlets such as Enter-PSSession, would Enter-ContainerSession be more appropriate than Enter-Container?
Pretty hard to get a single container right now
Hi, we see an issue NuGet/Home#3495 saying something with the new version of the OneGet (PackageManagement) provider 2.8.5.207. I looked your appveyor.yml, it looks like you are using:
WS2012R2+WMF5.1 Preview.
nuget.exe to create a docker.nupkg.
register a package source 'test' to the local folder
use oneget/powershellget to find-module and install-module from your local share.
If the above statement is correct, the nuget provider version should not impact you.
Also if you want PowerShellGet to find or install-module, your docker.nuspec must contain tags, for example, PSModule . Otherwise, there is no way for powershellget to find docker as module.
My recommendation is to update your .nuspec to add tags to include PSModule.
Due to some limitations in how the PowerShell package gets produced and consumed, we can't host both the Windows and the cross-platform PowerShell module in the same NuGet package. This means that if we want someone to try the cross-platform cmdlets, they are stuck building them directly themselves. Until we figure out the one package to rule them all, we need an interim solution where a separate feed can host the cross-platform module for anyone trying out the cmdlets on the new open source PowerShell.
Currently the Docker-PowerShell
module is named Docker
. It seems more reasonable to call it Docker-PowerShell
right?
The only changes would be:
> Install-Module Docker-PowerShell
> Import-Module Docker-PowerShell
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.