Skip to content

config.json in container and 'Device or resource busy' #3837

@robertkarbowski

Description

@robertkarbowski

Bug report information

Description

In docker-entrypoint.sh there is a command:

...
    mv config.json.tmp config.json
...

It works fine as long as no-one wants to mount external config.json file (docker run -v $(pwd)/config.json:/usr/src/app/config.json ...).
If so "docker" fails with the error:

mv: cannot move 'config.json.tmp' to 'config.json': Device or resource busy

The reason is that Linux does not allow to delete/rename mount points (mv uses actually rename() syscall).

One of the possible solutions is to replace "mv" with 2 commands:

--- old/docker-entrypoint.sh    2021-08-31 07:47:00.832079384 +0000
+++ new/docker-entrypoint.sh    2021-08-31 07:47:30.516815669 +0000
@@ -197,7 +197,8 @@
 
 if [[ $JQ_FILTERS_CONFIG != "." ]]; then
     jq "$JQ_FILTERS_CONFIG" config.json > config.json.tmp
-    mv config.json.tmp config.json
+    cp config.json.tmp config.json
+    rm config.json.tmp
 fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions