How to share a folder from container A to container B?

Viewed 33

I illustrated my problem through a diagram to complement my explanations:

enter image description here

To contextualize, I'm working with continuous integration, I have a host machine with jenkins running on that, and then through the script pipeline will execute containers A and B to perform their build (A) and static analysis (B) functions, in that order of execution. The reason to do the build beforehand is so that the compile_commands.json file is generated by MAKE.

The project is IoT(esp32) and I use the official espressif image to build it. The project folder is /var/lib/jenkins/workspace/iot-proj/ and it is on the jenkins machine (host) and I share its contents to containers through volumes. When the pipeline executes the command docker run -v $WORKSPACE/ESPComm:$WORKSPACE/ESPComm -w $WORKSPACE/ESPComm espressif/idf:v4.2.2 idf.py build, a build folder is created and inside it there is the file compile_commands.json, which will be used by cppcheck for static analysis. As this folder is shared across volumes, the compile_commands file later persists and container B imports smoothly.

The problem is that to compile the project there are espressif libraries in the opt/eso/idf/... folder and they are listed in the compile_commands.json and this folder is not accessible to container B when it runs cppcheck. How can I make this folder of espressif libraries that are in container A accessible in container B?


I tried this, but doesn't worked.. even with binfs https://github.com/moby/moby/issues/26872

sudo ls /proc/$(docker inspect --format {{.State.Pid}} YOUR_CONTAINER_NAME)/root


I had already read that the volume is only from the host to the container, even so I tried the command below and the folder is really empty: docker run -it -v $PWD:/project -v /opt/esp/idf/components/:/opt/esp/idf/components/ -w /project espressif/idf:v4.2.2


I thought I could easily solve my problem by adding these directories to a .suppressions file so that cppcheck ignores these files. I tried to do as I've done in other projects to pass the full path of the folder to be ignored, but it didn't work, the following error message appears in jenkins:

+ cppcheck --project=/var/lib/jenkins/workspace/iot-proj-TEST/ESPComm/build/compile_commands.json --inline-suppr --enable=all --suppress=missingInclude --suppress=unmatchedSuppression -- suppressions-list=/var/lib/jenkins/workspace/iot-proj-TEST/ESPComm/build/.suppressions --inconclusive --std=c11 --xml --xml-version=2 --std=c11
cppcheck: error: '/opt/esp/idf/components/xtensa/debug_helpers.c' from compilation database does not exist
cppcheck: error: failed to load project '/var/lib/jenkins/workspace/iot-proj-TEST/ESPComm/build/compile_commands.json'. An error occurred.
0 Answers
Related