Running Multiple Instances of Microsoft Teams Using Docker
Step-by-Step Guide
1. Create a Dockerfile
This Dockerfile sets up an environment to run Microsoft Teams using X11 forwarding to display the GUI on the host machine.
# Use the specified base image
FROM ubuntu:20.04
# Set proxy environment variables for the build process
# ENV http_proxy="http://<address>"
# ENV https_proxy="http://<address>"
# ENV ftp_proxy="http://<address>"
# ENV
# no_proxy="localhost,127.0.0.0/8,::1,192.168.0.0/16,*.local,*.comon"
# Run commands as root user
USER root
# add apt proxy to Dockerfile
# in Dockefile content
# RUN echo "Acquire::http::Proxy \"http://<address>\";" >> /etc/apt/apt.conf
# RUN echo "Acquire::https::Proxy \"http://<address>\";" >> /etc/apt/apt.conf
# Install necessary packages and dependencies
RUN apt-get update && \
apt-get install -y wget gnupg2 software-properties-common sudo && \
apt-get install -y \
libatk-bridge2.0-0 \
libatk1.0-0 \
libatspi2.0-0 \
libcairo2 \
libcups2 \
libgdk-pixbuf2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libxdamage1 \
libsecret-1-0 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Create a user to run the application and add to sudo group
RUN useradd -ms /bin/bash teamsuser && \
usermod -aG sudo teamsuser && \
echo "teamsuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER teamsuser
WORKDIR /home/teamsuser
# Download and install the latest Microsoft Teams package manually
RUN wget https://web.archive.org/web/20221130115842/https://packages.microsoft.com/repos/ms-teams/pool/main/t/teams/teams_1.5.00.23861_amd64.deb
# Install Microsoft Teams package and clean up
RUN sudo apt-get update && sudo apt-get install -y ./teams_1.5.00.23861_amd64.deb && \
rm -f ./teams_1.5.00.23861_amd64.deb
# Fix permissions for the configuration directory
RUN mkdir -p /home/teamsuser/.config/Microsoft && \
chown -R teamsuser:teamsuser /home/teamsuser/.config
RUN sudo apt-get update && \
sudo apt-get install -y x11-apps \
libxcb-shm0 libxcomposite1 libxcursor1 libxrandr2 libxrender1 \
libxslt1.1 libxtst6 libglib2.0-0 libgtk-3-bin libcanberra-gtk-module \
alsa-utils alsa-oss
# Set environment variable to avoid a warning
ENV QT_X11_NO_MITSHM=1
# Add default ALSA configuration
RUN echo 'pcm.!default {' > /home/teamsuser/.asoundrc && \
echo ' type hw' >> /home/teamsuser/.asoundrc && \
echo ' card 0' >> /home/teamsuser/.asoundrc && \
echo '}' >> /home/teamsuser/.asoundrc && \
echo 'ctl.!default {' >> /home/teamsuser/.asoundrc && \
echo ' type hw' >> /home/teamsuser/.asoundrc && \
echo ' card 0' >> /home/teamsuser/.asoundrc && \
echo '}' >> /home/teamsuser/.asoundrc && \
chown teamsuser:teamsuser /home/teamsuser/.asoundrc
# Command to run Microsoft Teams
CMD ["teams"]
2. Build the Docker Image
Install Docker via Command Line
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo systemctl status docker
sudo usermod -aG docker ${USER}
docker --version
Build the Docker image from the Dockerfile.
(note: if in Windows, could you install docker desktop and open terminal to run)
docker build -t teams-instance .
3. Prepare the Host Configuration Directory
Ensure the configuration directory on the host is set up with the correct permissions:
mkdir -p ~/.config/teams-instance1
sudo chown -R 1000:1000 ~/.config/teams-instance1 # Change ownership to match UID and GID of teamsuser in the container
4. Enable X11 Forwarding
Ensure X11 forwarding is enabled:
xhost +local:docker
(I did not verify it on windows :))With windows: install VcXsrv Windows X Server
Configure and Start VcXsrv:
-
Start VcXsrv using the “XLaunch” application.
-
Choose “Multiple windows” and click “Next.”
-
Select “Start no client” and click “Next.”
-
Check “Disable access control” and click “Finish.”
5. Run the Docker Container
Run the Docker container with the memory limit set and sufficient shared memory size:
docker run --rm --name teams1
-e DISPLAY=$DISPLAY
-v /tmp/.X11-unix:/tmp/.X11-unix
-v ~/.config/teams-instance1:/home/teamsuser/.config/Microsoft/Teams
--memory 4g
--shm-size=2g
-it teams-instance /bin/bash
6. Inside the Container
Once inside the container, let’s ensure that ALSA is correctly configured and start Microsoft Teams:
Check ALSA Configuration:
Verify the .asoundrc
file:
cat /home/teamsuser/.asoundrc
It should contain:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
7. Start Microsoft Teams
Start Microsoft Teams with verbose output:
mkdir -p "/home/teamsuser/.config/Microsoft/Microsoft Teams" touch "/home/teamsuser/.config/Microsoft/Microsoft Teams/hooks.json" teams --verbose
8. Check Logs
If Teams does not start correctly, check the logs for specific error messages:
cat /home/teamsuser/.config/Microsoft/Microsoft Teams/logs/teams-startup.log
9. Verify ALSA Devices
Verify if ALSA devices are recognized correctly:
aplay -l
10. Additional Debugging
Inspect Memory Usage:
While the container is running, keep an eye on memory usage to see if there are any spikes:
Verify Container Permissions:
Ensure the .asoundrc
file and the Teams configuration directory have the correct permissions:
sudo chown teamsuser:teamsuser /home/teamsuser/.asoundrc
sudo chown -R teamsuser:teamsuser /home/teamsuser/.config
By following these steps, you should be able to address both ALSA configuration issues and potential memory allocation problems, allowing Microsoft Teams to run smoothly inside the Docker container. If further issues arise, please provide additional details for further troubleshooting.