How to start Appium service automatically before test?

We are trying to create Appium test script for mobile GUI testing, and I am facing a problem that no instruction to guide us on how to start the Appium service before the test execution.
Currently, we are starting the Appium service manually in another terminal session before execute the Appium test of CodeceptJS, for example:

Terminal 1:

$ appium
[Appium] Welcome to Appium v1.20.2
[Appium] Appium REST http interface listener started on
^C[Appium] Received SIGINT - shutting down
[debug] [Appium] There are no active sessions for cleanup
[HTTP] Waiting until the server is closed
[HTTP] Received server close event

Terminal 2:

$ npm run codeceptjs

Is there any solution for starting the Appium service automatically before test?


We use dockerized Appium, for tests of native Android app and also mobile Chrome. When you build and run the docker container, it will be started again once you reboot your machine.


# Appium server for mobile tests

# Build image: 'docker-compose build --no-cache'
# Start container: 'docker-compose up -d'

# Ubuntu 20.04 LTS
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

# Install prerequisities
RUN apt-get update && apt-get -qqy install \
    curl \
    ca-certificates \
    openjdk-11-jre-headless \
    # Next packages are needed for ChromeDriver to be working 
    libglib2.0-0 \

# Install NodeJS
RUN curl -sL | bash -
RUN apt-get install -qqy nodejs

# Install Appium server
# ChromeDriver version must be compatible with Chrome version installed in emulator
# See the compatibility table at
RUN npm install -g appium@1.15 --chromedriver_version="90.0.4430.24" --unsafe-perm=true --allow-root

# Set ANDROID and JAVA env
ENV JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64

# Appium port

CMD appium --log-timestamp


version: "3.7"
    image: at/appium
    container_name: appium
      context: .
      - $HOME/Android/Sdk:/Android_Sdk
    restart: always
    network_mode: host # So that ADB docker's client can connect to ADB host's server

Thanks for your reply, it’s not inconvenient when developing the test script in the local working machine.
If CodeceptJS provide the Appium tick off solution such as WebDriverIO, it is less cost for the not strong skill programming skill of QA.

And I also will try your solution as we are running deploy the dockerization during CI process.