Docker is an open-source containerization platform for packaging, distributing, and running applications. It ensures that applications run consistently in different environments by packaging the application and all its dependencies into independent containers. Docker provides fast deployment, intense isolation, and efficient resource utilization and is widely used in development, testing, and production environments.
Android in Docker
The Android container is run in the host system through Docker. Using Docker's characteristics, we can map the host's device nodes to the Android container. The container and the host share a set of kernels, so the Android container can directly call the hardware acceleration units related to the Rockchip platform: GPU, VPU, NPU, RGA, etc.
Android in Docker Deployment
Host Deployment
Firefly organizes the host firmware corresponding to multiple models. Users only need to select the matching firmware version according to the specific model used and upgrade it to easily complete the host deployment.
Android Container Deployment
(1) If the host machine is connected to the Internet, the container folder can be efficiently transferred to the /userdata/ directory of the Linux host machine through the SCP command.
scp -r ./AIC/container root@xxx.xx.xx.xx:/userdata/
(2) Enter the container folder.
cd /userdata/container
(3) When starting for the first time, execute the initialization script.
./aic.sh -i
(4) After waiting for initialization to complete, execute.
-
./aic.sh -r <Android Image.tgz><Number of Containers>
Demo:
Note: The network uses port mapping by default.
<host ip>:1100 --> <container 0>:5555
<host ip>:1100 --> <container 1>:5555
....
If you need to make deeper customizations to the host or Android container, you can contact us to obtain the complete source code.
Debugging And Use
Container Management
(1) View all containers (including stopped containers).
docker ps -a
(2) Remove the Android container.
docker rm -f <container_id_or_name>
(3) Stop the running container.
-
docker stop <container_id_or_name>
(4) Launch a stopped container.
-
docker start <container_id_or_name>
Container Debugging
(1) Access a running container.
-
docker exec -it <container_id_or_name> sh
(2) View the CPU and memory usage of the container.
docker stats
(3) View all containers (including stopped containers).
docker cp local file container ID: path in container
(4) Move files from other devices in the LAN to the Docker container.
adb connect host IP: port number
adb -s 172.16.11.92:1102 push local file container ID: path in container
Note: Firefly's default docker network deployment is docker0 bridge mode, that is, port mapping scheme. If you modify it to use a macvlan network, the connect command needs to use the container IP plus port number 5555
adb connect container IP:5555
(5) Network screen transmission.
Use the open source scrcpy: https://github.com/Genymobile/scrcpy
scrcpy -s container IP: port number
Performance Testing
- Device: ITX-3588J
- Firmware: ITX-3588J_Ubuntu20.04-Minimal-r3104_v1.3.0c_241107.img
- Six Android systems running simultaneously on ITX-3588J
(1) Let the host run in performance mode.
# It is normal to get an Invalid argument, just ignore it
root@firefly:~# echo performance | tee $(find /sys/devices -name *governor)
performance
tee: /sys/devices/system/cpu/cpuidle/current_governor: Invalid argument
(2) Keep your CPU well-cooled, and keep the temperature below 80 degrees Celsius.
root@firefly:~# cat /sys/class/thermal/*/temp
54538
56384
56384
55461
52692
51769
52692
root@firefly:~# cat /sys/bus/cpu/devices/cpu*/cpufreq/cpuinfo_cur_freq
1800000
1800000
1800000
1800000
2256000
2256000
2256000
2256000
(3) Game test demonstration
In actual tests, we found that the RK3588 processor can efficiently run multiple Android systems in parallel at the highest performance state through AIC (Android in Docker) technology. However, when running 6 Android containers at the same time, since they share CPU resources, if the demand for the CPU of these containers surges at the same time, it may affect the user experience. In contrast, when running 4 Android containers, the pressure on the CPU is relatively moderate, and the impact between containers is relatively small. Therefore, according to the specific usage scenarios and needs, the number of containers to be opened can be flexibly determined.
With the excellent support of AIC technology, the potential of Firefly servers has been fully released. Using the Firefly B1 server equipped with RK3588 processor in a 10-node configuration, each node independently runs 6 Android systems, achieving parallel operation of 60 Android systems, demonstrating the powerful strength of AIC technology. The B2 server upgraded to 72 nodes has as many as 432 systems, significantly expanding the number of containers running Android.