Stefan Stranger's Blog

Running Universal Dashboard in a Linux Docker Container

2018-10-02 00:00:00 +0000 ·

For a project I’m currently working on I needed a Linux Docker container to run in Azure App Service for Linux.

Web App is a fully managed compute platform that is optimized for hosting websites and web applications. Customers can use App Service on Linux to host web apps natively on Linux for supported application stacks.

App Service on Linux supports a number of Built-in images in order to increase developer productivity. If the runtime your application requires is not supported in the built-in images, there are instructions on how to build your own Docker image to deploy to Web App for Containers.

I wanted to build my own Docker image and deploy that in later steps to the Web App for Containers.

In my opinion a good example for my custom Docker image is a simple Hello World Web page serviced by the PowerShell Module Universal Dashboard from Adam Driscoll.

Universal Dashboard

Universal Dashboard is a cross-platform PowerShell module for developing and hosting web-based interactive dashboards.

To create a Linux Docker container image with a Universal Dashboard I used the Ubuntu 18.04 PowerShell Core Docker image as a base for my dockerfile and added the Universal Dashboard Module and Universal Dashboard Hello World PowerShell script.

High-Level steps:

  1. Create a Universal Dashboard Hello World script.
  2. Create a dockerfile to create the custom Docker image.
  3. Create Docker image from dockerfile.
  4. Start Docker container.

Step 1. Create Universal Dashboard script.

Please look at the simple Hello World script stored as Gist.

Step 2: Create a dockerfile.

FROM mcr.microsoft.com/powershell:6.1.0-rc.1-ubuntu-18.04
RUN pwsh -c "Install-Module UniversalDashboard.Community -Acceptlicense -Force"
RUN pwsh -c "Invoke-WebRequest -Uri 'https://gist.githubusercontent.com/stefanstranger/cb74f5d78d7f4111c6c66915bc89a35f/raw/9a1ec9330a299593ef3d89925e0f88fc5c222641/HelloWorldUD-Example.ps1' -Method Get -OutFile /tmp/helloworldud-example.ps1"

CMD [ "pwsh","-command","& ./tmp/helloworldud-example.ps1" ]

Step 3. Create Docker image from dockerfile.

Open a PowerShell session and make sure you have installed the Docker for Windows Client if you are running Windows 10.

Remark: If you are using the Docker for Windows Client make sure you have switched to Linux Containers in the settings.

# Create Universal Dashboard Container image
docker build --rm -f "universaldashboard\dockerfile" -t universaldashboard:latest universaldashboard

Step 4: Start Docker container.

Open a PowerShell session and make sure you have installed the Docker for Windows Client if you are running Windows 10.

#run Universal Dashboard Container.
docker run -d -p 8585:8585 --name ud universaldashboard:latest

Your Universal Dashboard Hello World web page is now available on port 8585 and accessible in your browser.

Universal Dashboard running in Docker container

References:

  • Introduction to Azure App Service on Linux
  • Use a custom Docker image for Web App for Containers
  • Universal Dashboard
  • Powershell Core Docker image
  • Hello World Universal Dashboard script Gist








  • About
  • Contact
  • Search
  • Powered by Jekyll using the Trio theme