docker-android/README.md

288 lines
13 KiB
Markdown
Raw Normal View History

2017-11-23 20:03:12 +00:00
<p align="center">
<img id="header" src="./images/logo_dockerandroid_small.png" />
</p>
2016-12-22 13:29:57 +00:00
2019-01-30 13:58:31 +00:00
[![Analytics](https://ga-beacon.appspot.com/UA-133466903-1/github/budtmo/docker-android/README.md)](https://github.com/igrigorik/ga-beacon "Analytics")
2019-03-06 18:33:27 +00:00
[![Join the chat at https://gitter.im/budtmo/docker-android](https://badges.gitter.im/budtmo/docker-android.svg)](https://gitter.im/budtmo/docker-android?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2019-01-30 13:58:31 +00:00
[![Build Status](https://travis-ci.org/budtmo/docker-android.svg?branch=master)](https://travis-ci.org/budtmo/docker-android)
[![codecov](https://codecov.io/gh/budtmo/docker-android/branch/master/graph/badge.svg)](https://codecov.io/gh/budtmo/docker-android)
2017-05-24 11:01:10 +01:00
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3f000ffb97db45a59161814e1434c429)](https://www.codacy.com/app/butomo1989/docker-appium?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=butomo1989/docker-appium&amp;utm_campaign=Badge_Grade)
2019-01-31 09:40:19 +00:00
[![GitHub release](https://img.shields.io/github/release/budtmo/docker-android.svg)](https://github.com/budtmo/docker-android/releases)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbudtmo%2Fdocker-android.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbudtmo%2Fdocker-android?ref=badge_shield)
2019-02-11 09:42:37 +00:00
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
2016-12-22 13:33:30 +00:00
2018-04-23 18:25:24 +01:00
Docker-Android is a docker image built to be used for everything related to mobile website testing and Android project.
Emulator - Samsung Device | Emulator - Nexus Device | Real Device
:---------------------------:|:---------------------------:|:---------------------------:
![][emulator samsung] |![][emulator nexus] |![][real device]
2016-12-22 13:29:57 +00:00
2018-09-04 11:01:47 +01:00
Purposes
--------
2017-04-04 16:57:55 +01:00
2017-05-19 12:42:15 +01:00
1. Run UI tests for mobile websites with [appium]
2017-05-19 10:17:19 +01:00
2. Build Android project and run unit tests with the latest build-tools
3. Run UI tests for Android applications with different frameworks ([appium], [espresso], [robotium], etc.)
4. Run monkey / stress tests
5. SMS testing
2017-04-04 16:57:55 +01:00
2017-04-24 13:04:16 +01:00
Advantages compare with other docker-android projects
-----------------------------------------------------
2017-04-24 13:04:16 +01:00
1. noVNC to see what happen inside docker container
2017-05-19 10:17:19 +01:00
2. Emulator for different devices / skins, such as Samsung Galaxy S6, LG Nexus 4, HTC Nexus One and more.
3. Ability to connect to Selenium Grid
4. Ability to control emulator from outside container by using adb connect
2017-11-03 10:12:15 +00:00
5. Support real devices with screen mirroring
6. Ability to record video during test execution for debugging
2018-09-04 11:01:47 +01:00
7. Integrated with other cloud solutions, e.g. [Genymotion Cloud](https://www.genymotion.com/cloud/)
8. Open source with more features coming
2017-04-04 16:57:55 +01:00
List of Docker images
---------------------
2018-08-03 14:58:07 +01:00
|OS |Android |API |Browser |Browser version |Chromedriver |Image |Size |
2018-07-25 11:27:09 +01:00
|:---|:---|:---|:---|:---|:---|:---|:---|
2019-01-30 13:58:31 +00:00
|Linux|5.0.1|21|browser|37.0|2.21|budtmo/docker-android-x86-5.0.1|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-5.0.1.svg)](https://microbadger.com/images/budtmo/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")|
|Linux|5.1.1|22|browser|39.0|2.13|budtmo/docker-android-x86-5.1.1|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-5.1.1.svg)](https://microbadger.com/images/budtmo/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")|
|Linux|6.0|23|browser|44.0|2.18|budtmo/docker-android-x86-6.0|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-6.0.svg)](https://microbadger.com/images/budtmo/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|Linux|7.0|24|chrome|51.0|2.23|budtmo/docker-android-x86-7.0|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-7.0.svg)](https://microbadger.com/images/budtmo/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|Linux|7.1.1|25|chrome|55.0|2.28|budtmo/docker-android-x86-7.1.1|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-7.1.1.svg)](https://microbadger.com/images/budtmo/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|Linux|8.0|26|chrome|58.0|2.31|budtmo/docker-android-x86-8.0|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-8.0.svg)](https://microbadger.com/images/budtmo/docker-android-x86-8.0 "Get your own image badge on microbadger.com")|
|Linux|8.1|27|chrome|61.0|2.33|budtmo/docker-android-x86-8.1|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-8.1.svg)](https://microbadger.com/images/budtmo/docker-android-x86-8.1 "Get your own image badge on microbadger.com")|
|Linux|9.0|28|chrome|66.0|2.40|budtmo/docker-android-x86-9.0|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-9.0.svg)](https://microbadger.com/images/budtmo/docker-android-x86-9.0 "Get your own image badge on microbadger.com")|
2019-09-17 13:51:02 +01:00
|Linux|10.0|29|chrome|74.0|74.0.3729.6|budtmo/docker-android-x86-10.0|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-10.0.svg)](https://microbadger.com/images/budtmo/docker-android-x86-10.0 "Get your own image badge on microbadger.com")|
2020-07-13 12:03:58 +01:00
|Linux|11.0|30|chrome|83.0|83.0.4103.39|budtmo/docker-android-x86-11.0|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-x86-11.0.svg)](https://microbadger.com/images/budtmo/docker-android-x86-11.0 "Get your own image badge on microbadger.com")|
2019-01-30 13:58:31 +00:00
|All |-|-|-|-|-|budtmo/docker-android-real-device|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-real-device.svg)](https://microbadger.com/images/budtmo/docker-android-real-device "Get your own image badge on microbadger.com")|
2019-07-03 09:36:08 +01:00
|All|All|All|All|All|All|budtmo/docker-android-genymotion|[![](https://images.microbadger.com/badges/image/budtmo/docker-android-genymotion.svg)](https://microbadger.com/images/budtmo/docker-android-genymotion "Get your own image badge on microbadger.com")|
2017-04-24 13:04:16 +01:00
List of Devices
---------------
Type | Device Name
----- | -----
2019-07-26 15:56:21 +01:00
Phone | Samsung Galaxy S10
Phone | Samsung Galaxy S9
Phone | Samsung Galaxy S8
2019-03-11 15:53:37 +00:00
Phone | Samsung Galaxy S7 Edge
Phone | Samsung Galaxy S7
2017-04-24 13:04:16 +01:00
Phone | Samsung Galaxy S6
Phone | Nexus 4
Phone | Nexus 5
Phone | Nexus One
Phone | Nexus S
Tablet | Nexus 7
Requirements
------------
Docker is installed in your system.
2016-12-22 13:29:57 +00:00
Quick Start
-----------
2018-09-04 11:01:47 +01:00
1. Run Docker-Android
2016-12-22 13:29:57 +00:00
2017-04-26 10:34:38 +01:00
- For ***Linux OS***, please use image name that contains "x86"
```bash
2019-01-30 13:58:31 +00:00
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container budtmo/docker-android-x86-8.1
2017-04-26 10:34:38 +01:00
```
2018-07-06 09:33:17 +01:00
- For ***OSX*** and ***Windows OS***, please use Virtual Machine that support Virtualization with Ubuntu OS
2017-04-26 10:34:38 +01:00
2017-02-28 14:36:43 +00:00
2017-04-24 13:04:16 +01:00
2. Verify the ip address of docker host.
2016-12-22 13:29:57 +00:00
2017-01-08 16:24:38 +00:00
- For OSX, you can find out by using following command:
2016-12-22 13:29:57 +00:00
2017-02-11 22:37:27 +00:00
```bash
docker-machine ip default
```
2016-12-22 13:29:57 +00:00
2017-01-08 16:24:38 +00:00
- For different OS, localhost should work.
2020-06-17 16:14:57 +01:00
3. Open ***http://docker-host-ip-address:6080*** from web browser. Note: Adding ```?view_only=true``` will give user only view only permission.
2017-01-08 16:24:38 +00:00
2018-09-04 11:01:47 +01:00
Custom configurations
---------------------
2018-09-04 11:01:47 +01:00
[This document](README_CUSTOM_CONFIG.md) contains custom configurations of Docker-Android that you might need, e.g. Proxy, Changing language on fly, etc.
2017-05-29 13:34:35 +01:00
Build Android project
---------------------
2018-09-04 11:01:47 +01:00
Docker-Android can be used for building Android project and executing its unit test. This following steps will illustrate how to build Android project:
1. Clone [this sample test project](https://github.com/android/testing-samples).
2018-09-04 11:01:47 +01:00
```bash
git clone git@github.com:android/testing-samples.git
2018-09-04 11:01:47 +01:00
```
2. Build the project
2018-09-04 11:01:47 +01:00
```bash
2020-01-17 21:30:19 +00:00
docker run -it --rm -v $PWD/testing-samples/ui/espresso/BasicSample:/tmp -w /tmp budtmo/docker-android-x86-8.1 /tmp/gradlew build
2018-09-04 11:01:47 +01:00
```
Control Android connected to host (Emulator or Real Device)
-----------------------------------------------------------
1. Create a docker container with this command
```
2019-01-30 13:58:31 +00:00
$ docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 --name android-container-appium budtmo/docker-android-real-device
```
2. Open noVNC [http://localhost:6080](http://localhost:6080)
3. Open terminal by clicking right on **noVNC** window >> **Terminal emulator**
4. To connect to host's adb (make sure your host have adb and connected to the device.)
```
$ adb -H host.docker.internal devices
```
To specify port, just add `-P port_number`
```
$ adb -H host.docker.internal -P 5037 devices
```
5. Now your container can access your host devices. But, you need to add `remoteAdbHost` and `adbPort` desired capabilities to make **Appium** can recognise those devices.
2018-06-22 01:24:34 +01:00
2018-09-04 11:01:47 +01:00
Appium and Selenium Grid
------------------------
2018-06-25 22:53:06 +01:00
2018-09-04 11:01:47 +01:00
If you want to use Appium and Selenium Grid, you can follow [this document](README_APPIUM_AND_SELENIUM.md). It also contains sample and use cases.
2018-06-12 00:05:35 +01:00
2017-04-12 13:25:12 +01:00
Control android emulator outside container
------------------------------------------
```bash
adb connect <docker-machine-ip-address>:5555
```
![][adb_connection]
2018-07-19 11:39:16 +01:00
**Note:** You need to have Android Debug Bridge (adb) installed in your host machine.
2017-04-12 13:25:12 +01:00
SMS Simulation
--------------
1. Using telnet
- Find the auth_token and copy it.
```bash
docker exec -it android-container cat /root/.emulator_console_auth_token
```
- Access emulator using telnet and login with auth_token
```bash
telnet <docker-machine-ip-address> 5554
```
- Login with given auth_token from 1.step
```bash
auth <auth_token>
```
- Send the sms
```bash
sms send <phone_number> <message>
```
2. Using adb
```bash
docker exec -it android-container adb emu sms send <phone_number> <message>
```
2017-04-24 13:04:16 +01:00
3. You can also integrate it inside project using adb library.
2017-04-12 13:25:12 +01:00
![][sms]
2018-09-04 11:01:47 +01:00
Google Play Services and Google Play Store
------------------------------------------
Not installed at this time.
2018-03-05 10:37:19 +00:00
2019-03-06 14:57:45 +00:00
Jenkins
-------
This [document](README_JENKINS.md) gives you information about custom plugin that supports Docker-Android.
2018-09-04 11:01:47 +01:00
VMWARE
------
2018-06-18 23:01:33 +01:00
2018-09-04 11:01:47 +01:00
This [document](README_VMWARE.md) shows you how to configure Virtual Machine on VMWARE to be able to run Docker-Android.
2018-06-18 23:01:33 +01:00
2018-09-04 11:01:47 +01:00
Cloud
-----
2018-06-18 23:01:33 +01:00
2018-09-04 11:01:47 +01:00
This [document](README_CLOUD.md) contains information about deploying Docker-Android on cloud services.
2018-06-18 23:01:33 +01:00
2018-09-04 11:01:47 +01:00
Genymotion
----------
2019-01-02 12:30:45 +00:00
<p align="center">
<img id="geny" src="./images/logo_genymotion_and_dockerandroid.png" />
</p>
For you who do not have ressources to maintain the simulator or to buy machines or need different device profiles, you need to give a try to [Genymotion Cloud](https://www.genymotion.com/cloud/). Docker-Android is integrated with Genymotion on different cloud services, e.g. Genymotion Cloud, AWS, GCP, Alibaba Cloud. Please follow [this document](README_GENYMOTION.md) or [this blog](https://medium.com/genymobile/run-your-appium-tests-using-docker-android-genymotion-cloud-e4817132ccd8) for more detail.
2017-02-28 14:36:43 +00:00
Troubleshooting
---------------
All logs inside container are stored under folder **/var/log/supervisor**. you can print out log file by using **docker exec**. Example:
```bash
2017-04-26 13:19:46 +01:00
docker exec -it android-container tail -f /var/log/supervisor/docker-android.stdout.log
2017-02-28 14:36:43 +00:00
```
2019-03-11 16:10:02 +00:00
Emulator Skins
--------------
2019-07-26 15:56:21 +01:00
The Emulator skins are taken from [Android Studio IDE](https://developer.android.com/studio) and [Samsung Developer Website](e)
2019-03-11 16:10:02 +00:00
2019-05-06 12:33:13 +01:00
Security
--------
2020-07-14 08:54:31 +01:00
All docker images are protected by [Polyverse](https://polyverse.io/) by scrambling the Linux packages. For more information please visit [this link](https://youtu.be/eSZNP42n-pM)
2019-05-06 12:33:13 +01:00
2020-09-02 10:33:07 +01:00
Monitoring
----------
You can use [cadvisor](https://github.com/google/cadvisor) combined with influxdb / prometheus and grafana if needed to monitor each running container.
2020-07-13 13:20:51 +01:00
Users
-----
Docker-Android are being used by 100+ countries around the world.
2020-07-14 08:50:31 +01:00
[![ga-datastudio-docker-android](./images/docker-android_users.png)](https://datastudio.google.com/s/ht7HVKHKAQE)
2020-07-13 13:20:51 +01:00
2020-07-22 08:12:27 +01:00
Stargazers over time
--------------------
[![Stargazers over time](https://starchart.cc/budtmo/docker-android.svg)](https://starchart.cc/budtmo/docker-android)
2017-11-23 20:03:12 +00:00
Special Thanks
--------------
- [Gian Christanto] for creating a great logo!
2018-10-26 14:03:44 +01:00
LICENSE
--------------
2018-10-26 14:05:14 +01:00
See [License](LICENSE.md)
2018-10-26 14:03:44 +01:00
2019-02-14 12:20:11 +00:00
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbudtmo%2Fdocker-android.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbudtmo%2Fdocker-android?ref=badge_large)
2017-04-24 13:04:16 +01:00
[appium]: <https://appium.io>
2018-09-14 15:19:46 +01:00
[espresso]: <https://developer.android.com/training/testing/espresso/>
2017-05-19 10:17:19 +01:00
[robotium]: <https://github.com/RobotiumTech/robotium>
[emulator samsung]: <images/emulator_samsung_galaxy_s6.png>
[emulator nexus]: <images/emulator_nexus_5.png>
[real device]: <images/real_device.png>
2017-04-12 13:25:12 +01:00
[adb_connection]: <images/adb_connection.png>
[sms]: <images/SMS.png>
2017-11-23 20:03:12 +00:00
[gian christanto]: <https://www.linkedin.com/in/gian-christanto-0b398b131/>