5.Enter docker container5.1、related concepts5.2、How to query the docker image version used by the robot5.3、Binding peripherals5.4、Edit scripts5.5、Execute scripts5.6、multiple terminals enter the same docker container5.7、How to open a container that is already in the [Exited] closed state5.7.1、enter the [Exited] closed container again
xxxxxxxxxx
The host is the server where we call the command to create a container using the image. This refers to our system motherboard (jetson board or Raspberry PI, etc.), and the host machine mentioned below refers to this.
xxxxxxxxxx
GUI is the graphical user interface, which mainly refers to: the image window displayed by opencv, rviz interface, rqt interface, etc.
xxxxxxxxxx
When the docker image is open and running, it is the container
1、The docker image version used by the robot is also the mirror version used on the trolley, and the user executes after the system image of the burned trolley is started:
xxxxxxxxxx
jetson@jetson-desktop:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
yahboomtechnology/ros2-base 2.0.1 fce9745648c0 3 days ago 6.5GB
yahboomtechnology/ros2-base 1.0.3 cs41dfas5fx0 3 days ago 6.9GB
yahboomtechnology/ros2-base 1.0.1 31e97028c1c0 3 days ago 7.2GB
You will see that there are multiple docker image versions, please select the name which is the highest tag version is the latest image version of the board. The actual situation is displayed based on the mirror you have queried.
2、Why can't you just put a docker image in the car system?
If you have read the tutorial in the chapter [ Docker ------ 3, docker images to deeply understand and release images], you should know that docker images are layered mechanisms, 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, and the tags of these images will be updated incrementally.
In the future, we will update the new course, and we will also update the function by releasing a new docker image
The following uses Radar and serial device bonding as an example
This step is performed on the host::
1、Here is to view peripherals other than the camera
xxxxxxxxxx
ll /dev | grep ttyUSB*
2、View camera device
xxxxxxxxxx
ls /dev/video*
Then edit the startup script according to the device found in the previous step
The following uses Radar and serial device bonding as an example
Edit the script that runs docker,This step is performed on the host:
1、Create a docker run script [run_usb_docker.sh], It's usually in the home directory
xxxxxxxxxx
chmod +x run_usb_docker.sh #Give the script executable permissions
【run_usb_docker.sh】The contents of the script are as follows:
Without comments, you can copy it directly and modify it as needed
Note: When adding a host device to a container below, if the host does not have the device connected, you need to remove the corresponding add operation to open the container
x#!/bin/bash
xhost +
docker run -it \
--net=host \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /home/jetson/temp:/root/yahboomcar_ros2_ws/temp \
--device=/dev/video0 \
--device=/dev/myserial \
--device=/dev/rplidar \
-p 9090:9090 \
-p 8888:8888 \
yahboomtechnology/ros2-base:2.0.2 /bin/bash
Here is the annotated script description:
Note: When adding a host device to a container below, if the host does not have the device connected, you need to remove the corresponding add operation to open the container
xxxxxxxxxx
#!/bin/bash
xhost + # xhost is used to support displaying GUIs in docker
docker run -it \ # Run docker images interactively
--net=host \ # The container network is set to host mode
--env="DISPLAY" \ # Open the display GUI interface
--env="QT_X11_NO_MITSHM=1" \ # Port 1 of X11 is used for display
-v /tmp/.X11-unix:/tmp/.X11-unix \ # map shows the service node directory
-v /home/jetson/temp:/root/yahboomcar_ros2_ws/temp \ # As a directory for the host and container to temporarily transfer files, you can use this directory if you need to transfer files
--device=/dev/video0 \ # Add the video device to the container, No camera connected, please remove this line
--device=/dev/myserial \ # Add the serial device to the container, No serial device connected, please remove this line
--device=/dev/rplidar \ # Add the radar device to the container, No radar device connected, please remove this line
-p 9090:9090 \ # Open port
-p 8888:8888 \
yahboomtechnology/ros2-base:2.0.2 /bin/bash # The name of the image to be started, according to the modification queried in step 5.2; execute the /bin/bash command inside the container
After the 5.4 step is completed, ,open the terminal on the host of docker(can be on VNC or on the screen of the board)
Note: Here must be executed on the VNC of the trolley or on the trolley screen, not in the trolley terminal entered remotely through ssh (such as the trolley terminal entered through MobaXterm), otherwise the GUI image may not be displayed in the container,as follows in MobaXterm into the trolley terminal execution run_docker.sh after entering the container, rviz cannot be displayed
Run the startup script you created earlier on the VNC interface or on the screen
(Note: Each time this script is executed, a new container is created from the image.)
xxxxxxxxxx
./run_usb_docker.sh
The container can be entered correctly, and the GUI screen can be displayed, and the rviz2 command test can be executed again.
xxxxxxxxxx
rviz2
If the GUI cannot be displayed after executing the rviz2 command, the following error is displayed: (Generally, it may appear in the Raspberry Pi )
You need to add another parameter to the startup script:
xxxxxxxxxx
--security-opt apparmor:unconfined
such as:
xxxxxxxxxx
#!/bin/bash
xhost +
docker run -it \
--net=host \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--security-opt apparmor:unconfined \ # Added this parameter
-v /home/jetson/temp:/root/yahboomcar_ros2_ws/temp \
--device=/dev/video0 \
--device=/dev/myserial \
--device=/dev/rplidar \
-p 9090:9090 \
-p 8888:8888 \
yahboomtechnology/ros2-base:2.0.2 /bin/bash
Then run the script again to enter the container and display the GUI screen.
1、In the above steps, a docker container has been opened, and another terminal can be opened on the host to view:
xxxxxxxxxx
docker ps -a
2、Now enter the docker container in this newly opened terminal:
xxxxxxxxxx
docker exec -it [container id] /bin/bash
example:
Successfully entering the container, you can also open an unlimited number of terminals to enter the container.
3、Note:
(1)When executing the command in step 2, make sure that the container is in the [UP] state
(2)If the container is in the Exited shutdown state, see Step 5.7 below
There are two cases here:: Cameras and other related external equipment changes and Cameras and other related external equipment not changes(See step 5.3 Checking Peripheral Connections)
1、Cameras and other related external equipment changes
If there are changes in the container that need to be preserved, can generate a new image by referring to the following command(See the previous tutorial for detailed steps to publish an image)
xxxxxxxxxx
# Commit an image from the container:
docker commit [container id] [Target image name to be created:[tag]]
For example:docker commit 66c40ede8c68 yahboomtechnology/ros-foxy:1.1 # tag names increment according to your own situation
Then run this new image into the container: see steps 5.2 to 5.5 in this section
2、Cameras and other related external equipment not changes,then directly refer to the [5.7.1、enter the [Exited] closed container again] step to execute.
Open the terminal on the docker's host ( can be on VNC or on the screen of the matherboard )
Note: Here must be executed on the VNC of the board or on the screen of the board, not in the board terminal entered remotely through ssh, otherwise the GUI image may not be displayed in the container, of course, how you do not need to display the GUI image, then you can.
1、First, check the status of the container
xxxxxxxxxx
docker ps -a
2、Enable GUI access permissions
xxxxxxxxxx
xhost +
3、Open the container [the ID of the container here can be abbreviated, as long as it can uniquely identify the container that currently exists]
xxxxxxxxxx
docker start [container ID]
4、Enter the container again
xxxxxxxxxx
docker exec -it [container ID] /bin/bash
5、Open rviz to see if the GUI screen can be opened
rviz2