How to run Appium client script in Docker image of Appium?

We are going to execute the Appium client scripts(Core Java) in Docker image of Appium Android in which Appium server is running as Docker image. Appium client request will reach the Appium server running as docker image and the same Appium server interact with the real mobile device for executing the user actions.

What is Docker?

Docker containers are lightweight by design and ideal for enabling microservices application development. Accelerate development, deployment and rollback of tens or hundreds of containers composed as a single application. Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud.

What is Virtual Box?

A VirtualBox or VB is a software virtualization package that installs on an operating system as an application. VirtualBox allows additional operating systems to be installed on it, as a Guest OS, and run in a virtual environment.

Please refer the step by step information to implement Appium docker image in Mac OS X based on the GitHub reference link as mentioned below;;

Step 1: Download and Install Docker Community Edition in your Mac using the below URL;

Please note, Require Mac OS Yosemite 10.10.3 or above and follow the steps mentioned in the below URL to ensure Docker is successfully installed and running in your Mac;  (Go for stable release)

Ensure Docker installed successfully by running the below command in terminal window;

$ docker-machine –version

Step 2: Download and Install Virtual Box in your Mac including the Extension pack as mentioned in the below URL;

Install the virtual box first before try to install the below extension pack package;

Step 3: Create a docker machine by running the below command in terminal window;

$ docker-machine create –driver virtualbox appium-test-machine

Step 4: Enable USB in docker image to connect the real device;

$ docker-machine stop appium-test-machine

$ vboxmanage modifyvm appium-test-machine –usb on –usbehci on

$ docker-machine start appium-test-machine

Step 5: Open Virtual Box and enable Android device and USB Host controller as follows;

5.1 Open Virtual Box

5.2 Select Ports tab

5.3 Select USB tab

5.4 Click pencil with + symbol

5.5 Select Android device

5.6 Again click pencil with + symbol

5.7 Select USB Host controller

Please refer the below screenshot for your reference;


Step 6: Connect the Appium machine using SSH command as follows;

$ docker-machine ssh appium-test-machine

Step 7: Run the docker image, which is nothing but the Appium Server; (Connect real device using USB cable before executing the below command)

$ docker run –privileged -d -p 4723:4723  -v /dev/bus/usb:/dev/bus/usb –name container-appium appium/appium

It will pull the latest appium checkin based on the below information;


Step 8: Ensure device connected with the docker image by running the below command;

$ docker exec -it container-appium adb devices


Step 9: Run the Appium client script in Eclipse IDE as mentioned below by taking the IP address of Appium Docker image;

Get the secondary Appium docker image IP address in the network setting or boot docker window as mentioned in the below screenshot;


public class DockerTest {

public static void main(String[] args) throws MalformedURLException, InterruptedException {

AndroidDriver<WebElement> driver = null;

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(“deviceName”, “testdevice”);

capabilities.setCapability(“platformName”, “Android”);

capabilities.setCapability(“browserName”, “Chrome”);

driver = new AndroidDriver<WebElement>(new URL(“;), capabilities);

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);





Please refer the below video for script execution in docker image with real-device in place;

5 thoughts on “How to run Appium client script in Docker image of Appium?

  1. I have followed till step number 7, while checking the connected device,
    docker exec -it container-appium adb devices
    List of devices attached

    It does not show any attached devices, but a Android device has been attached for that


  2. thanks for explanation Gopi. However, even after following all steps exactly i am not able to get the list of connected devices. Its coming empty.
    I am on Mac OSX High Sierra.


  3. Hello. Is there any reason to create the container inside a docker machine rather than creating it directly on the host ? It works fine either way. Thanks.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s