Docker image to run your appium test against a defined Android emulador and SDK
Based on vbanthia's idea but parametrized and based on Docker Ubuntu 14.04.
I really appreciate Pablo M. Sobrado's contributions because, without him, this project wouldn't exist.
This docker image is designed to run on Linux systems, may not work on Windows. You will need at least 25GB per build.
You can build your Docker image running the Dockerfile with the following command:
$ docker build -t agomezmoron/docker-appium . && docker rmi -f $(docker images -f "dangling=true" -q) &> /dev/null
or pulling it from docker:
$ docker pull agomezmoron/docker-appium
You can specify the Java and Appium version, the Android SDK or the VNC password to use with the following variables (the values used are the default ones):
JAVA_VERSION=8
ANDROID_SDK_VERSION=23
VNC_PASSWD=1234
APPIUM_VERSION=1.5.2
Usage:
$ docker build --build-arg JAVA_VERSION=8 --build-arg ANDROID_SDK_VERSION=23 --build-arg VNC_PASSWD=1234 -t agomezmoron/docker-appium . && docker rmi -f $(docker images -f "dangling=true" -q) &> /dev/null
Java:
Android SDK:
The second part of the command, '&& docker rmi -f $(docker images -f "dangling=true" -q) &> /dev/null', is an optional one that deletes past images of the builds so the PC does not end up with several duplicated images. It can be removed without affecting the build.
Run the image with the following command:
$ docker run --privileged -v /YOUR/SOURCES/FOLDER:/src -v /YOUR/TARGET/FOLDER:/src/target -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e DOCKER_TESTS_COMMAND="YOUR_MAVEN_COMMAND" --rm -t -i -p 5900:5900 agomezmoron/docker-appium
Please note that you WILL have to specify your sources folder for appium to run, AS WELL as a target folder for when it ends. Also, you MUST input a maven command, for example:
mvn test -Pandroid,ci
You can choose to update the SDK when running the image. This may be useful in some cases. Just specify it like this:
UPDATE="y"
The run command will create an Android emulator before launching it. You can specify its CPU and device with the following variables (the values used are the default ones):
DEVICE="Nexus S"
ABI="default/x86_64"
Usage:
$ docker run --privileged -v /YOUR/SOURCES/FOLDER:/src -v /YOUR/TARGET/FOLDER:/src/target -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e DOCKER_TESTS_COMMAND="YOUR_MAVEN_COMMAND" -e DEVICE="Nexus S" -e ABI="default/x86_64" -e UPDATE="y" --rm -t -i --net=host agomezmoron/docker-appium
ABIs (CPUs):
Devices:
Open Remmina, a built-in app in Ubuntu. Configure a new connection like this:
Name: Whatever you like
Protocol: VNC - Virtual Network Computing
Server: localhost
Username: ubuntu / 'empty'
Password: Your chosen VNC password. If none was given in the build, use '1234'.
Click on 'Connect' -or 'Save' if you want to store the connection for further uses- and you should be able to see the emulator, as long as the image is up and running.
You can try first stopping and removing the images:
$ docker stop $(docker ps -a -q) && docker rm -f $(docker ps -a -q)
then deleting them with docker rmi -f image_id. You can check the images ids by running:
$ docker images
You can try first stopping and removing the images:
$ docker stop $(docker ps -a -q) && docker rm -f $(docker ps -a -q)
then running the image again and reconnecting. If the connection still fails, try restarting the docker daemon:
$ sudo service docker restart