Run Android Emulator on Docker

How to build and run Android Emulator on a Docker container, run locally on MacBook. Assumption Docker is installed. I learned about Docker from this GitHub tutorial. In this tutorial, we will create and run an Android Emulator inside a Docker container.

1. Pull the Android Docker images.

a. Open Docker application on MacBook.

b. Open a new terminal and enter below commands:

2. Modified below command to use your file ssh key path “../../ssh/id_rsa.pub”

3. Open new terminal and SSH into container. Use below command to install Android emulator components

ssh to Docker container

Enter below commands to download Android emulator components:

Enter below commands to create new Android Emulator:

Command create Android emulator API 24

4. The Android emulator is starting inside Docker container

Now VNC to the container. With VNC you are able to see the emulator. You will have an android emulator running on your virtual machine “container”

a. On MacBook open application “Screen Sharing”.

b. Enter below:

5. Open new terminal and enter below ADB commands.

Since the sdk container is persisted on host machine (`-v $(pwd)/sdk:/sdk`), we don’t need to install the emulator packages after the first run,We just need to open terminal and enter below command.

The Docker container running the Android emulator keeps running until you stop/kill docker container. Below Docker commands shows how to stop docker container:

The goal: is to be able to build and run Android emulators on the cloud, and be able to run android Espresso test on cloud. For some reason android emulator performance is a bit poor. ARM emulator is slow, X86 is preferred, but that needs a physical Linux machine with KVM enabled.

Good tutorial about Android Docker

TODO: Learned how to deploy docker container to AWS.

Let me know if you have any questions, thanks. -Andres

software engineer, read, swim, travel. apps: https://goo.gl/rDuuQw https://goo.gl/15GvfE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store