Welcome to ROSMASTER M1 repository
4. Enter Docker (For JETSON Nano and RPi 5)
Entering Docker
This lesson is for the Raspberry Pi 5 and Jetson Nano boards. The Orin board does not require Docker.
Conceptual Understanding:
We refer to the Raspberry Pi/Jetson Nano main environment as the host, and the Docker environment as Docker. Except for the communication agent, which runs on the host, all other programs on the Raspberry Pi/Jetson Nano run within Docker. The host terminal displays the username "jetson/pi," while the Docker username is "root."
1. First Entry into Docker
The Raspberry Pi 5 and Jetson Nano boards will automatically boot into the Docker controller startup program (run_humble.sh), and will mount the controller connected to USB into Docker. To ensure the smooth operation of the controller startup program, this Docker container does not mount devices such as the voice module and myserial before starting. Therefore, subsequent programs cannot use this Docker container; a new Docker container with multiple mounted devices needs to be started using a script.
Enter Docker (ensure the voice module and control board are connected to the motherboard/HUB before entering)
xxxxxxxxxxsh ~/run_humble.sh
After entering the Docker terminal, the current directory is /. Generally, we need to enter commands in the /root directory. Therefore, enter cd in the Docker terminal and press Enter to enter the /root directory and view files.
Entering the same container from multiple terminals:
Since Docker starts automatically on boot and only has one terminal, it's impossible to enter other commands simultaneously in one terminal. We need to know how to use multiple terminals to run within the same container.
On your Raspberry Pi 5 and Jetson Nano, enter the following command to query information about the container created when you first enter Docker:
xxxxxxxxxxdocker ps

As shown in the image above, the above content appears, displaying the image as 192.168.2.51:5000/ros-humble-a1:1.0.0. This corresponds to the image name in our run_humble.sh, indicating that this is the container created by executing sh run_humble.sh, and its name is intelligent_sutherland. The name generated by each user will be different; refer to the actual situation you encounter when querying, as long as the image name matches. We will then use this container name to enter Docker.
Enter the following command on the host machine to enter this container:
xxxxxxxxxxdocker exec -it intelligent_sutherland /bin/bash#ordocker exec -it 0f6ed945ea52 /bin/bashintelligent_sutherland or its ID should be modified according to the actual container being created. Press Enter to enter the Docker terminal. This is the terminal we enter when starting the Docker container for the first time. Subsequent program commands need to be entered in the terminal of this Docker container.
2. Non-First Entry
2.1 Entering a Previous Docker Container After a Restart
Sometimes, we modify the code in the Docker container we entered for the first time, and then restart or shut down the machine. If we enter the Docker container using the same method as when we first entered it, we will find that the previous modifications are gone. This is because we restarted a new Docker container, which naturally does not contain our previous modifications. If we need to enter the Docker container again after shutting down the machine, we need to follow these steps: Query the Docker container name or ID, Restart the Docker container, and then enter the Docker container.
Enter the following command to query the Docker container you first entered:
xxxxxxxxxxdocker ps -aThis will list all containers, including those that are running or not. We determine which container to start based on when we first entered the Docker container. For example, if I started the car Docker container 3 minutes ago, I found that the container's name is intelligent_sutherland, and its ID is 0f6ed945ea52, as shown in the image below:

Then, enter the following command in the terminal to restart the car Docker container:
xxxxxxxxxxdocker restart intelligent_sutherland#or docker restart 0f6ed945ea52
intelligent_sutherland or the ID should be modified according to the actual container being queried. This command only needs to be started once after the vehicle restarts.
Enter the following command in the terminal to enter the vehicle's Docker container:
xxxxxxxxxxdocker exec -it intelligent_sutherland /bin/bash#ordocker exec -it 0f6ed945ea52 /bin/bash
Press Enter to enter the Docker terminal. This is the terminal of the Docker container we enter for the first time. Subsequent program commands need to be entered in the terminal of this Docker container.
If you need to access the terminal after a reboot and the program you're running needs to display a graphical interface, then you need to enter the following command in the vehicle's terminal:
xxxxxxxxxxxhost +
2.2 Entering a New Docker Container
- Ensure the existing Docker container is shut down, and run the following command to enable the new container:
xxxxxxxxxxsh ~/run_humble.sh
- Run the above command to enter the same container program in multiple terminals.