Ubuntu Docker Container Git Submodule

Hi all,

I’ve created a Docker image that I use to (bind) mount a folder where there is my C/C++ project. The project is under GIT control where I use also submodules. Inside the container when I try to add a GIT submodule I receive this error:

error: could not write config file .gitmodules: Device or resource busy

Is there someone that use GIT submodule inside a Linux container mounted with the “bind” option?

Thanks a lot!

I’m using vscode to run the container and to manage the project. The default user is “root” so I think I have the necessary permissions to write the file. Below you can see the output of “ls -al” command.

root@4a80811ca394:/workspaces/Template_STM32H563# ls -al
total 28
drwxrwxrwx 1 root root 4096 Jul 5 12:26 .
drwxr-xr-x 3 root root 4096 Jul 8 09:28 …
-rwxrwxrwx 1 root root 4012 Jul 1 14:35 .clang-format
drwxrwxrwx 1 root root 4096 Jul 5 16:37 .devcontainer
drwxrwxrwx 1 root root 4096 Jul 5 16:37 .git
-rwxrwxrwx 1 root root 49 Jul 1 14:35 .gitignore
drwxrwxrwx 1 root root 4096 Jul 5 12:24 .gitmodule
-rwxrwxrwx 1 root root 453 Jul 1 14:35 .gitmodules
drwxrwxrwx 1 root root 4096 Jul 3 15:13 .vscode
-rwxrwxrwx 1 root root 5096 Jul 5 12:26 CMakeLists.txt
-rwxrwxrwx 1 root root 672 Jul 1 14:35 CMakePresets.json
drwxrwxrwx 1 root root 4096 Jul 1 14:35 ECLAIR
-rwxrwxrwx 1 root root 41 Jun 25 13:49 LICENSE.md
-rwxrwxrwx 1 root root 21 Jun 25 13:49 README.md
drwxrwxrwx 1 root root 4096 Jul 1 14:35 app
-rwxrwxrwx 1 root root 1047 Jul 1 14:35 arm-none-eabi-toolchain.cmake
drwxr-xr-x 1 root root 4096 Jun 25 15:32 build
-rwxrwxrwx 1 root root 599 Jul 1 14:35 build.sh
-rwxrwxrwx 1 root root 514 Jul 1 14:35 clean.sh
-rwxrwxrwx 1 root root 735 Jul 1 14:35 config.cmake
-rwxrwxrwx 1 root root 1272 Jul 1 14:35 flags.cmake
drwxrwxrwx 1 root root 4096 Jul 1 14:35 jlink
drwxrwxrwx 1 root root 4096 Jun 25 13:51 libraries

Sometimes I’m able to write to the file sometimes no.

WORKING:

root@4a80811ca394:/workspaces/Template_STM32H563# git submodule add --force https://github.com/stm32_mw_freertos.git libraries/middlewares/freertos
Adding existing repo at ‘libraries/middlewares/freertos’ to the index

ERROR EXAMPLE:

root@4a80811ca394:/workspaces/Template_STM32H563# git submodule add --force https://github.com/stm32_mw_freertos.git libraries/middlewares/freertos
Adding existing repo at ‘libraries/middlewares/freertos’ to the index
fatal: please make sure that the .gitmodules file is in the working tree

Thanks a lot for the support.

Giulio