SDK Image Compilation (Docker Environment)
1. Introduction to Docker
Docker is a lightweight containerization platform used to package, distribute, and run applications and their dependencies. Based on container technology, Docker packages an application and all required runtime environments into an independent and portable container, ensuring consistent behavior across different environments. This greatly improves development, deployment, and scaling efficiency. Docker defines applications and their runtime environments through images, and runs them through containers. Containers can run seamlessly on any operating system or cloud platform that supports Docker, while remaining lightweight, efficient, and isolated.
- Container: Docker uses containers to package applications and all their dependencies, including code, runtime, system tools, and system libraries. Containers provide a lightweight, consistent, and portable way to run applications in different environments.
- Image: An image is the basis of a container. It contains all information required to run the container, such as the filesystem, libraries, and configuration. Images can be shared, stored in repositories, and transferred over the network.
- Repository: Images are stored in repositories for centralized management and sharing. Docker supports public repositories, such as Docker Hub, and private repositories. Users can pull required images from repositories, or push custom images for others to use or deploy.
-
Install Docker tools, namely the Docker engine.
sudo apt install docker.io -y -
Get the Docker image. Users in China are recommended to download the offline image directly.
sudo docker pull luckfoxtech/luckfox_pico:1.0 -
Get the offline Docker image.
Version Description Download luckfoxtech/luckfox_pico 1.0 Offline Docker image download Docker Baidu Netdisk link # Install the Docker imagesudo docker load -i ./luckfox_pico_docker.tar
The operations above only install Docker on the system, which is equivalent to installing the container runtime platform. To run a container, you still need to explicitly start one with commands such as docker run or docker start.
2. Build Images with Docker
- Get the latest SDK. You can choose either of the following methods. Gitee is recommended for users in China.
git clone https://gitee.com/LuckfoxTECH/luckfox-pico.gitgit clone https://github.com/LuckfoxTECH/luckfox-pico.git
- Start an interactive container named
luckfox, map the SDK directory on the host to/homeinside the container, and run it with Bash.sudo docker run -it --name luckfox --privileged -v /home/ubuntu/luckfox-pico:/home luckfoxtech/luckfox_pico:1.0 /bin/bash-it: Runs an interactive container.--name: Specifies a container name, making the container easier to identify and manage.-v: Mounts a directory or file from the host into the container. In the example above,/home/ubuntu/luckfox-picoon the host is mounted to/homeinside the container.
- If the container already exists, use the following command to start it again.
sudo docker start -ai luckfox
- Before compilation, select the code branch that matches the actual development board model to ensure that the compiled image can run correctly.
root@b165d8d4c29b:# cd /homeroot@807131c0df36:/home# ./build.sh lunchYou're building on LinuxLunch menu...pick the Luckfox Pico hardware version:选择 Luckfox Pico 硬件版本:[0] RV1103_Luckfox_Pico[1] RV1103_Luckfox_Pico_Mini[2] RV1103_Luckfox_Pico_Plus[3] RV1103_Luckfox_Pico_WebBee[4] RV1106_Luckfox_Pico_Pro_Max[5] RV1106_Luckfox_Pico_Ultra[6] RV1106_Luckfox_Pico_Pi[7] RV1106_Luckfox_Pico_86Panel[8] RV1106_Luckfox_Pico_Zero[9] customWhich would you like? [0~9][default:0]: 5Lunch menu...pick the boot medium:选择启动媒介:[0] EMMCWhich would you like? [0][default:0]: 0Lunch menu...pick the system version:选择系统版本:[0] BuildrootWhich would you like? [0][default:0]: 0[build.sh:info] Lunching for Default BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Ultra-IPC.mk boards...[build.sh:info] switching to board: /home/ubuntu/Luckfox/rv1106/sdk-latest/luckfox-pico/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Ultra-IPC.mk[build.sh:info] Running build_select_board succeeded.root@807131c0df36:/home# ./build.sh
3. Add the User to the Docker Group
On Ubuntu, Docker commands need sudo by default because the Docker daemon runs with root privileges. Docker performs privileged operations such as accessing system resources, managing containers, building images, and mounting filesystems. If you do not want to use sudo every time you run Docker commands, add the current user to the docker group.
- Run the following command to add the current user to the
dockergroup.sudo usermod -aG docker $USER - Log out and log in again, or run the following commands to make the change take effect.
sudo service docker restartnewgrp docker
- Make sure that the user
luckfoxhas been added to thedockergroup.id luckfox
4. Common Docker Commands
The following are some common Docker commands. To view the complete command list and help information, run docker --help.
- Image-related commands.
docker pull luckfoxtech/luckfox_pico:1.0 # Download the image from Docker Hubdocker images # List all local imagesdocker rmi luckfoxtech/luckfox_pico:1.0 # Delete one or more local imagesdocker search [image] # Search for an image on Docker Hub
- Container-related commands.
docker ps # List currently running containersdocker ps -a # List all containers, including stopped containers
- Container operations.
docker start 1758 # Start a stopped containerdocker stop 1758 # Stop a running containerdocker restart 1758 # Restart a containerdocker exec -it 1758 ls # Execute a command in a running containerdocker exec -it 1758 bash # Enter an already running containerdocker rm 1758 # Delete one or more containersexit # Exit
- Run a container.
sudo docker run -it --name luckfox --privileged -v /home/ubuntu/luckfox-pico:/home luckfoxtech/luckfox_pico:1.0 /bin/bash
-it: Runs an interactive container.--name: Specifies a container name, making the container easier to identify and manage.-v: Mounts a directory or file from the host into the container. In the example above,/home/ubuntu/luckfox-picoon the host is mounted to/homeinside the container.
- If the container already exists, use the following command to start it again.
sudo docker start -ai luckfox
- System information.
docker logs 1758 # View container logsdocker inspect 1758 # View detailed container informationdocker rmi luckfoxtech/luckfox_pico:1.0 # Delete one or more local imagesdocker top 1758 # View processes running in the container
- A Docker container ID is unique. In most cases, the first few characters are enough to identify a container. Replace the example container ID with your own container ID, or its prefix, when running the commands.