Created
May 26, 2020 16:12
-
-
Save Siniliote/6a839bbf84d7a512319c9351134d0e83 to your computer and use it in GitHub Desktop.
PowerShell with docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Prompt(){ | |
$W = Split-Path -leaf -path (Get-Location) | |
$prompt = Write-Prompt "$($env:UserName)@$($env:ComputerName):" -ForegroundColor Green | |
$prompt += Write-Prompt $W -ForegroundColor DarkCyan | |
$prompt += Write-Prompt '>' | |
return ' ' | |
} | |
function Remove-StoppedContainers { | |
docker container rm $(docker container ls -q) | |
} | |
Set-Alias drm Remove-StoppedContainers | |
function Remove-AllContainers { | |
docker container rm -f $(docker container ls -aq) | |
} | |
Set-Alias drmf Remove-AllContainers | |
function Get-ContainerIPAddress { | |
param ( | |
[String] $id | |
) | |
& docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' $id | |
} | |
Set-Alias dip Get-ContainerIPAddress | |
function Add-ContainerIpToHosts { | |
param ( | |
[String] $name | |
) | |
$ip = docker inspect --format '{{ .NetworkSettings.Networks.nat.IPAddress }}' $name | |
$newEntry = "$ip $name #added by d2h# `r`n" | |
$path = 'C:\Windows\System32\drivers\etc\hosts' | |
$newEntry + (Get-Content $path -Raw) | Set-Content $path | |
} | |
Set-Alias d2h Add-ContainerIpToHosts | |
function UpgradeChoco { | |
Start-Process powershell.exe -Verb RunAs 'choco upgrade all' | |
} | |
Set-Alias chup UpgradeChoco | |
function docmd { docker run --rm --interactive --tty $args } | |
function composer { docker run --rm --interactive --tty --volume ${PWD}:/app composer $args } | |
function php { docker run --rm --interactive --tty php $args } | |
function node { docker run --rm --interactive --tty node $args } | |
function jenkins { docker run -d -v C:/www/jenkins-project:/var/jenkins_home -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts } | |
function magick { docker run --rm --interactive --tty --volume ${PWD}:/app sferey/imagemagick $args } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment