Docker hardware interaction and data processing

4.1. Hardware mounting (port binding)

  1. Create udev rules in the host machine (/etc/udev/rules.d/), see [VI. Linux operating system ---- 6. Binding device ID] section
  2. Then when starting the container, mount the devices with the rules set into the docker container through parameters such as --device=/dev/myserial --device=/dev/rplidar
  1. The device can be found in the docker container

 

4.2. Display of GUI in docker

  1. Install in the host machine:
  1. Execute in the host machine: xhost +

After the following figure is displayed normally, perform 3 steps:

0

  1. Execute the command in the host machine to enter the container, and pay attention to modify the corresponding version number:

You can also edit the startup script, name it new_jetcobot_docker.sh, and run the following command to enter the container.

  1. Testing

 

4.3, Transfer files between docker container and host

4.3.1, Use cp naming

4.3.1.1, Copy files from container to host

 

4.3.1.2. Copy files from the host to the container

 

4.3.2. Using Data Volumes

4.3.2.1. Data Volume Overview

Package the application and the running environment into a container to run. The running can be accompanied by the container, but our requirement for data is that it can be persistent! For example, if you install a mysql, and then you delete the container, it is equivalent to deleting the library and running away. This is definitely not okay! So we hope that it is possible to share data between containers. If the data generated by the docker container is not generated through docker commit, so that the data is saved as part of the image, then when the container is deleted, the data will naturally disappear! This will not work!

In order to save data in docker, we can use volumes! Let the data be mounted locally! In this way, the data will not be lost due to container deletion!

Features:

  1. Data volumes can share or reuse data between containers
  2. Changes in the volume can take effect directly
  3. Changes in the data volume will not be included in the update of the image
  4. The life cycle of the data volume lasts until no container uses it

4.3.2.2, Data volume usage