Forum Discussion
Osamabinsaleem
Dec 11, 2023Copper Contributor
Running MS Teams on Linux in a dockerized envrironment with MS Edge
I'm trying to run Microsoft Teams inside a docker container that is running ubuntu 22.04. I've installed MS Edge and webdriver. I'm using selenium with python to automate this. When I try to go to this url (using the selenium script) https://teams.microsoft.com/ , I see a sign-in page. After signing in, the script never moves forward to the Teams page. Instead it keeps on loading this page https://teams.live.com/_ . I tried the same with Chrome browser in a docker environment and I was getting similar behaviour.
These are the edge options for the selenium script:
edge_options.add_argument("--no-sandbox") edge_options.use_chromium = True edge_options.add_argument("--disable-gpu") edge_options.add_argument("--disable-dev-shm-usage") edge_options.add_argument("--disable-extensions") edge_options.add_argument("--disable-infobars") edge_options.add_argument("--window-size=1280x720") edge_options.add_argument("--enable-logging") edge_options.add_argument("--v=1") edge_options.add_argument("--ignore-certificate-errors") edge_options.add_argument("--ignore-ssl-errors") edge_options.add_argument("--use-fake-ui-for-media-stream") edge_options.add_argument("--disable-features=msEdgeSync") edge_options.add_argument("--disable-blink-features=AutomationControlled") edge_options.add_argument("-disable-default-apps") chrome_prefs = { "profile.default_content_settings": {"cookies": 1}, "profile.block_third_party_cookies": False, # ... other preferences } edge_options.add_experimental_option("prefs", chrome_prefs) edge_options.add_experimental_option("excludeSwitches", ["enable-automation"])
and this is my docker file:
FROM ubuntu:latest # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive # Install dependencies required for Edge RUN apt-get update && apt-get install -y \ wget \ gnupg \ software-properties-common \ xvfb \ unzip # Add Microsoft Edge repository RUN wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | apt-key add - \ && add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" # Add your downloaded .deb file to the container COPY microsoft-edge-stable_119.0.2151.97-1_amd64.deb /tmp/ # Install Microsoft Edge RUN dpkg -i /tmp/microsoft-edge-stable_119.0.2151.97-1_amd64.deb || \ apt-get install -f -y && \ rm -f /tmp/microsoft-edge-stable_119.0.2151.97-1_amd64.deb # Check if the Microsoft Edge binary exists and output the version. RUN which microsoft-edge-stable RUN microsoft-edge-stable --version || true RUN EDGE_DRIVER_VERSION="119.0.2151.97" && \ echo "Edge Driver Version: ${EDGE_DRIVER_VERSION}" && \ wget -q https://msedgedriver.azureedge.net/${EDGE_DRIVER_VERSION}/edgedriver_linux64.zip && \ unzip edgedriver_linux64.zip && \ mv msedgedriver /usr/local/bin/ && \ chmod +x /usr/local/bin/msedgedriver && \ rm edgedriver_linux64.zip # Set display port to avoid crash ENV DISPLAY=:99 # Clean up RUN apt-get clean && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip3 install --no-cache-dir -r requirements.txt # Install sudo RUN apt-get update && apt-get install -y sudo UN groupadd -r chrome && \ useradd -r -m -g chrome -G audio,video,sudo chrome && \ mkdir -p /home/chrome/user_data && \ mkdir -p /home/chrome/reports && \ chown -R chrome:chrome /home/chrome && \ chmod -R 777 /home/chrome/user_data # Give chrome user passwordless sudo privileges RUN echo 'chrome ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/chrome && \ chmod 0440 /etc/sudoers.d/chrome RUN mkdir -p /etc/opt/chrome/policies/managed/ # Create the JSON file with the policy RUN echo '{ \ "ExternalProtocolDialogShowAlwaysOpenCheckbox": true, \ "URLAllowlist": [ "https://*", "ms-teams:*", "teams.live.com*" ] \ }' > /etc/opt/chrome/policies/managed/managed_policies.json # Adjust permissions on the file and directory RUN chmod -R 775 /etc/opt/chrome/policies/managed # Switch to chrome user USER chrome WORKDIR /home/chrome COPY . . # Copy the Python script COPY --chown=chrome:chrome . /home/chrome # Expose the port the app runs on EXPOSE 3000 RUN chmod +x /home/chrome/start.sh # Start with the shell script ENTRYPOINT ["/home/chrome/start.sh"]
No RepliesBe the first to reply