I have a Docker image that runs Appium server and Android Emulator. I am totally able to run a container based on that image in my computer (it requires the --privileged flag for that). I am also able to run automated tests in the emulator without any issues.
Now, I would like to run the emulator on Bitbucket pipelines. However, Bitbucket pipelines don't allow starting a Docker container with --privileged (and many other Docker flags) by security reasons. As I understood, this flag is responsible for running the emulator.
I also tried to add to the Docker image to the bitbucket-pipelines.yml file, hoping that I would be able to run the emulator directly in the host, instead of inside a container, but didn't work either, I got empty result from the commands "adb devices" and "emulator -list-avds"
Does anyone know anything that could help achieve this goal? I mean, running automated UI tests on Android in Bitbucket pipelines?
Yes it is possible. There are several answers in the link below, which do not require using the --privileged
flag:
In the answer of Ming C, there is a linked GitHub page which has a guide on how to run the emulator in the Docker machine:
However, as of April 2025, there are various problems trying to run an Android emulator inside Docker container:
For these reasons, I recommend using an alternative service to run unit tests or UI tests in a CI build. Your CI build will need to send the built app to an online service, then run the tests in that third-party service, and then retrieve the results. Some example services are: