Build Microsoft Teams PowerShell Docker Image Using Dockerfile

In this blog post, I will show you how to create a Dockerfile for Microsoft Teams PowerShell administration.

Using Microsoft official PowerShell 7 Core Docker Container image, we can manage MS Teams for Docker.

The image is using Ubuntu Linux image, and the Dockerfile installs the latest beta version the Teams module.

Dockerfile

The first step in this process will be creating a Dockerfile using the following command.

Note: I am using CentOS 7.7

nano dockerfile

Next, I will copy and paste the lines below to the file and save.

From mcr.microsoft.com/powershell
RUN pwsh -command register-PSRepository -Name PSGalleryInt -SourceLocation https://www.poshtestgallery.com/ -InstallationPolicy Trusted
RUN pwsh -command install-Module microsoftteams -Repository PSGalleryInt
CMD ["pwsh"]

Build Image

To build the image, I will run the following command.

Note: The image name will be msteams.

docker build -t msteams .

 Run and log in to MS Teams

The final step will be deploying a container from the image using the command below:

docker container run -it  msteams

After the container started, I will import the MS Teams module using the line below:

Import-module microsoftteams

To connect, I will type:

Connect-Microsoftteams

Processing…
Success! You're on the list.

Posted

in

,

by

Comments

One response to “Build Microsoft Teams PowerShell Docker Image Using Dockerfile”

  1. Phil Avatar
    Phil

    Thank you, that is brilliant. I ran it on my Mac and it works great. Any reason not to put the lines:

    Import-module microsoftteams
    Connect-Microsoftteams

    in the dockerfile?

    Cheers,
    Phil