BYO Docker PowerShell Container

I’ve been seeing a lot of buzz out there about the release of the open source version of PowerShell by Microsoft. When looking at the GitHub documentation, I found the documentation for building a PowerShell container with these new bits just a little bit confusing, so in this post I’ll quickly go into how to get it done.

While launching a container hosted in the Docker hub is easy, for images that are not up on the the hub sometimes you need to build your own. That’s what’s happening here. In this case, we need to clone of the github repo and build the container.

Step one – Get Docker:

Grab the latest docker bits here. Install them, and get back here.

Step two – Get Git:

Grab git for your host here.

Step three – Clone the Github version of PowerShell:

Change to a directory on your machine where you’re okay having the powershell files downloaded. I use a directory under my home directory called github_work.

Execute the following git command which will download the PowerShell files into a directory called PowerShell:

git clone --recursive

Step four – Build that Docker container:

Change directories into the PowerShell directory:change-dirs

Boom… see that file called Dockerfile? That’s the file that will tell the Docker engine how to build the docker image that can be executed.

Let’s build! From the powershell directory type the following:

docker build -t powershell .

Lots of awesome output should ensue! Great for making your coworkers wonder what the heck are they doing over there?


Step Four (and a half): Verify that your image is there!

Let’s use docker to quickly verify that our image exists locally to be executed now. Do that by executing:

docker images


Looking good. We can see that the PowerShell image is built and also you’ll notice that ubuntu has been downloaded… The reasoning behind this is simple… our Dockerfile specifies that we should use that image as the base for our powershell build. Here you see that specified in the first line: FROM ubuntu:16:04


Step Five: Be Awesome!

Time for some PowerShell. You’ll see that the last line of the dockerfile describes the Entrypoint for the container. Basically specifying the command that is executed automatically when the container is started. In this case it looks like we just need to interactively start the container. Do that by executing the following:

docker run -it powershell



More to come here… Stay tuned.

2 Responses

  1. TedSpinks says:

    Wow, that is really cool!

  1. September 9, 2016

    […] In a previous post, I showed you how to build a powershell docker image from the powershell github repo using the included powershell Dockerfile. Before we jump into more complicated things, let’s first focus on some of the basic options for executing containers: […]

Leave a Reply

Your email address will not be published. Required fields are marked *