I’m currently using the official Docker Hub Playwright image for my Node.js-based tests, which works great for browser dependencies. However, I now need to integrate the TestRail CLI to upload reports, and it requires Python—which isn’t included in the default Playwright Docker image.
Is the best approach to create a custom Dockerfile extending the Playwright image and install Python manually? Or is there a cleaner method that works well with GitLab CI? I’m relatively new to Docker and would appreciate a simple and reliable setup that doesn’t require reworking all existing test logic.
Any suggestions for the smoothest way to enhance the Playwright Docker setup with Python support?
I’ve worked with CI pipelines for a while now, especially with Playwright on GitLab—and ran into this when we needed Python for some analytics scripts post-tests. The solution that worked best for us was simply extending the Docker Hub Playwright image using a custom Dockerfile:
FROM mcr.microsoft.com/playwright:v1.43.1-jammy
RUN apt-get update && apt-get install -y python3 python3-pip
We kept this in the same repo alongside our .gitlab-ci.yml
. No changes to our test logic, and it gave us a clean, fast-booting container with both the browser dependencies and Python tools pre-installed. Super straightforward if you’re just starting out with docker hub playwright-based setups.
Yeah, been there too. I’ve been managing CI setups for a while and we hit a similar need, only in our case, it was for pushing test results to Allure using Python tools. Building on what Tom shared, I went a bit further by layering in some Python packages directly in the Dockerfile. So instead of tweaking the pipeline, we baked everything into our docker hub playwright image like this:
FROM mcr.microsoft.com/playwright:latest
RUN apt-get update && \
apt-get install -y python3 python3-pip && \
pip install testrail-cli
What really helped was caching this image in our GitLab Container Registry. That cut build times and kept our CI pipeline lean and reproducible. If you’re working regularly with docker hub playwright images, pre-building and caching is a game-changer.