Using Docker to Create an Image
- Obtain Kbox container startup dependencies base_box.sh and bin, upload them to the /home/kbox_instruction directory (this directory is used as an example and can be customized) on the server, and create a Kbox image. For details, see "Software Deployment" in the Kbox Cloud Phone Container Feature Guide.
- Upload CloudPhoneInstructionEngine.tar.gz, InstructionPhoneAndroidRServer.tar.gz, and InstructionPhoneClientSmokeApk.tar.gz to the /home/kbox_instruction directory on the server.
- Decompress InstructionPhoneAndroidRServer.tar.gz to obtain the image creation scripts make_image.sh and Dockerfile and instance startup script cfct, and save them to the /home/kbox_instruction directory.
1 2 3
cd /home/kbox_instruction tar xf InstructionPhoneAndroidRServer.tar.gz cfct Dockerfile make_image.sh chmod +x cfct make_image.sh base_box.sh bin/*
- Create an image.
Run the make_image.sh script to generate a Docker image.
In the command, ${tar_package} is InstructionPhoneAndroidRServer.tar.gz. The first ${image_name:tag} indicates the name and tag of the original image. The second ${image_name:tag} indicates the name and tag of the new image.
1./make_image.sh ${tar_package} ${image_name:tag} ${image_name:tag}
- You are advised to run the chown -R root:root command to ensure that the owner and group of the file are root.
- Dockerfile description:
- ORIGIN_IMAGE in FROM ${ORIGIN_IMAGE} is the existing Kbox image. (This document uses the Kbox image as the base image. You can modify it as required. There is a possibility that some images are not supported.) Check whether the Kbox image name is correct based on your settings.
- The RUN chown -R root:root instructionImage command is used to change the owner and group of the file to root (recommended). This document uses this command as an example. The functions of other RUN commands are similar to those of basic Linux commands.
- The ADD ./instructionEngine/vendor /instructionImage/vendor command is used to copy the files in the local folder (instructionEngine/vendor) to the directory (instructionImage/vendor) for making a Docker image. Other ADD commands are similar.
- Check whether the image is generated.
Run the docker command to check whether the image is correctly generated and whether the generated image name exists.
1docker images
To migrate the created image to another server, perform the following steps:
- Run the docker save -o android.tar kbox:0101 command to save the image. In the command, android.tar is the image name, and kbox:0101 is the existing environment image name.
- Place android.tar in the environment where the instruction stream cloud phone is running properly, and then run the docker load -i android.tar command to load the image to the environment.
- Run the docker images command to check that the kbox:0101 image exists in the environment.
- Start the instruction stream cloud phone.
In the following commands, ${image_name:tag} indicates the name and tag of the new Kbox image created in 4. ${kbox_id} indicates the ID of the started instruction stream cloud phone instance, which can be customized.
1 2
cd /home/kbox_instruction ./cfct run ${image_name:tag} ${kbox_id} docker
The recommended ID of an instruction stream cloud phone instance ranges from 1 to 100. If the ID is not within the range, the instruction stream cloud phone may fail to be started.
- Check whether the instruction stream cloud phone is started successfully. ${kbox_id} indicates the ID of the instance.
1 2 3
docker exec -it kbox_${kbox_id} sh getprop sys.boot_completed getprop vmi.agent.status
In the output, if the value of getprop sys.boot_completed is 1 and the value of getprop vmi.agent.status is true, the startup is successful.
- Decompress InstructionPhoneClientSmokeApk.tar.gz and install CloudGame_Smoke.apk on the Android mobile phone. Enter the server IP address and port number of the started instance (for example, 8066, where 66 is the ID of the instruction stream cloud phone instance) in top-down order to access the instruction stream cloud phone.
- The instruction stream engine client is 64-bit and must run on a 64-bit Android phone with HarmonyOS or Android 7.0 or later. If this condition is not met, the cloud phone client cannot be installed.
- Ensure that the network connection between the Android mobile phone and the server is normal.