Enter docker container

 

  1. What is the host of docker
  1. What is GUI
  1. What is the docker container of the robot
  1. Before operating this chapter tutorial, please make sure that you have mastered the knowledge of the following chapters, otherwise you may find it difficult to learn. In this case, please check the following pre-knowledge content repeatedly, and you will feel very relaxed after mastering it. Come on, you are the best!

image-20230519094253521

5.2, How to query the docker image version used by the robot

  1. The docker image version used by the robot is also the image version used on the car. After the user burns the system image of the car and starts it, execute:

Please select the name [yahboomtechnologyros-humble]. The version with the highest tag is the latest image version of the robot

  1. Why can't we just put one docker image in the car system?

If you have read the tutorial in [13, Docker ------ 3, docker image in-depth understanding and release image], you should know that docker image is a layered mechanism, that is, the image of the latter tag depends on the image of the previous tag. Therefore, there may be multiple versions of docker images in the host machine, and the tags of these images will be updated in an incremental manner.

Later, when we update new courses, we will also update functions by releasing new docker images.

5.3. Edit scripts

Edit the script to run docker. This step is performed on the host machine:

  1. The script to run docker [docker_ros2.sh] is generally placed in the root directory of the car's home directory. I am in the following path. If you don't have it, you can create the file yourself. Remember to give the script executable permissions after creation.

image-20230423164551252

The contents of the [docker_ros2.sh] script are as follows:

You can copy it directly without comments and modify it as needed

Note: When adding a host device to a container below, if the host machine is not connected to the device, you need to remove the corresponding addition operation to start the container

Annotated script description:

Note: When adding a host device to a container, if the host is not connected to the device, you need to remove the corresponding addition operation to start the container.

5.4, Execute the script

Note: This must be executed on the VNC of the car or on the car screen. It cannot be executed in the car terminal remotely entered through ssh (such as the car terminal entered through MobaXterm). Otherwise, the GUI image may not be displayed in the container. As shown below, after entering the car terminal in MobaXterm and executing run_docker.sh to enter the container, rviz cannot be displayed

image-20230423173220146

Execute on the VNC interface of the car or on the car screen:

You can enter the container correctly and display the GUI screen. You can execute the rviz2 command again for testing.

image-20230423171929960

If the GUI cannot be displayed after executing the rviz2 command, the following error is displayed: (usually it may appear in the Raspberry Pi master)

image-20230509173232054

You need to add another parameter to the startup script:

That is:

Then run the script again to enter the container and display the GUI screen.

5.5. multiple terminals enter the same docker container

 

  1. In the above steps, a docker container has been opened. You can open another terminal on the host (car) to view it:
  1. Now open a new terminal and enter the same docker. Change the following da8c4f47020a to the ID displayed in the actual terminal

image-20230423182446607

After successfully entering the container, you can open countless terminals to enter the container.

The robot project files are stored in the following directory:

5.6, how to open a container that is already in the [Exited] closed state

5.6.1, re-enter the container in the [Exited] closed state

Open the terminal on the docker host [i.e. the car, which can be executed on VNC or on the car screen]

Note: This must be executed on the car's VNC or on the car screen, and cannot be executed in the car terminal remotely entered through ssh (such as the car terminal entered through MobaXterm), otherwise the GUI image may not be displayed in the container. Of course, if you do not need to display the GUI image, then it is OK.

  1. First check the status of the container
  1. Enable GUI access
  1. Enable the container [the container ID here can be abbreviated as long as it can uniquely identify the existing container]
  1. Enter the container again
  1. Open rviz to check whether the GUI screen can be opened
  1. The specific execution is as follows: