Using Docker to Create an Image
- Obtain Kbox container startup dependency base_box.sh, upload it 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.
#cd /home/kbox_instruction #tar xf InstructionPhoneAndroidRServer.tar.gz cfct Dockerfile make_image.sh #chmod +x cfct make_image.sh base_box.sh
- 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.
# ./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 based on the site requirements. Note that there is a possibility that some images are not supported.) Check whether the Kbox image name is correct based on the site requirements.
- RUN chown -R root:root instructionImage: This 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.
- ADD ./instructionEngine/vendor /instructionImage/vendor: This 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.
# docker 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 step 4. ${kbox_id} indicates the ID of the started instruction stream cloud phone instance, which can be customized.
# 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.
# docker exec -it kbox_${kbox_id} sh # getprop sys.boot_completed # getprop vmi.agent.statusIn 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 mobile phone OS must be Android 7.0 or later. Otherwise, the cloud phone client cannot be installed.
- Ensure that the network connection between the Android mobile phone and the server is normal.