google / android-emulator-container-scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the healthcheck of these emulators under Docker?

gounthar opened this issue Β· comments

Hi there,

First of all, thanks for this set of images, they are very useful to me. πŸ™
I have a complex (to me) set of services defined in a docker-compose.yml file, and I have depends-on definition for services depending on the emulator.

For the time being, I have hardcoded sleep time in temporary services because even if docker says the emulator service is up and running, the emulator hasn't finished booting for some time...

    [...]
    emulator:
        platform: linux/amd64
        image: us-docker.pkg.dev/android-emulator-268719/images/30-google-x64:30.1.2
        restart: unless-stopped
        ports:
            - 8554:8554
            - 5555:5555
        environment:
            - ADBKEY
        devices:
            - /dev/kvm
        healthcheck:
            test: [ "CMD", "???", "???, "???" ]
            interval: 5s
            timeout: 3s
            retries: 10
            start_period: 15s
    adb-connector:
        container_name: adb-connector
        build: ./adb-connector
        privileged: true
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock:rw
        command:
            - sleep 30 && docker exec adb adb connect emulator:5555 
        depends_on:
            - adb
            - emulator
    [...]

I would like to get rid of the sleep and use a healthcheck command on the emulator container.
Does the Dockerfile already defines a healthcheck?
Is there any healthcheck command you think of that could help me knowing when the emulator is ready? I thought of an adb command but it's not part of the docker image.

Thank you.

        healthcheck:
            test: [ "CMD", "/android/sdk/platform-tools/adb", " connect", "localhost:5555" ]
            interval: 5s
            timeout: 3s
            retries: 10
            start_period: 15s

Works fine for me.

@dduportal gave me a hint. docker inspect gives me the information I was looking for:

 "Healthcheck": {
                "Test": [
                    "CMD-SHELL",
                    "/android/sdk/platform-tools/adb shell getprop dev.bootcomplete | grep \"1\""
                ],
                "Interval": 30000000000,
                "Timeout": 30000000000,
                "StartPeriod": 30000000000,
                "Retries": 3
            },