Skip to content

Instantly share code, notes, and snippets.

@laidbackware
Created June 10, 2021 10:24
Show Gist options
  • Save laidbackware/9c5ff63c1da1eb9a1aceebbada62d43f to your computer and use it in GitHub Desktop.
Save laidbackware/9c5ff63c1da1eb9a1aceebbada62d43f to your computer and use it in GitHub Desktop.
Powershell Docker with PowerCLI
FROM ubuntu:20.04
RUN set -xe \
&& echo "Update the list of packages" \
&& apt-get update \
&& echo "Install pre-requisite packages." \
&& apt-get install -y wget apt-transport-https software-properties-common \
&& echo "Download the Microsoft repository GPG keys" \
&& wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb \
&& echo "Register the Microsoft repository GPG keys" \
&& dpkg -i packages-microsoft-prod.deb \
&& echo "Update the list of products" \
&& apt-get update \
&& echo "Enable the "universe" repositories" \
&& add-apt-repository universe \
&& echo "Install PowerShell" \
&& apt-get install -y powershell
RUN set -xe \
&& pwsh --command 'Install-Module VMware.PowerCLI -Scope CurrentUser -Confirm:$False -Force'

Build

docker build . -t laidbackware/pwsh:latest docker push laidbackware/pwsh:latest

Run bash with local directory as volume

docker run -it --rm --volume ${PWD}:/local_dir laidbackware/pwsh:latest bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment