microsoft / Docker-PowerShell

PowerShell Module for Docker
MIT License
289 stars 87 forks source link

We need a Find-ContainerImage for docker search #183

Open thomasmaurer opened 7 years ago

thomasmaurer commented 7 years ago

Output of $PSVersionTable (from a powershell process): Name Value


PSVersion 5.1.15063.296 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.15063.296 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 (paste your output here)


**Output of `ipmo Docker; (module Docker).Version.ToString()` (from a powershell process):**

0.1.0.111



**Steps to reproduce the issue:**
1. Open PowerShell
2. try to use find-containerimage
3.

**What actually happened?:**
Nothing ;-)

**What did you expect to happen?:**
search the default registry like docker search

**Additional information:**
JohnCroix commented 6 years ago

like this? :)

function Find-ContainerImage{
    Param(
        [Parameter(
        Position = 0,
        Mandatory=$false, 
        ValueFromPipeline=$true,
        ValueFromPipelineByPropertyName=$true)]
        [string]$ContainerName = "microsoft/*"
    )
    $i = 1
    $FoundContainer = docker search --format "{{.Name}}" $ContainerName 
    $FoundContainer | %{
        "$i. $_"
        $i++ 
    }
    IF ($FoundContainer.count -gt 1){
        $Select = Read-Host "Please make a selection"
        return $FoundContainer[$($Select-1)]
    }ELSE{
        return $FoundContainer[0]
    }
}

Find-ContainerImage 'microsoft/mssql'