Catalogue
Working around "Text file busy" when a shell script fails to run during docker build

Working around "Text file busy" when a shell script fails to run during docker build

🌐 日本語で読む

Overview

I had written a shell execution inside a Dockerfile like the following.

1
2
RUN chmod +x hoge.sh \
&& hoge.sh

When I ran docker build with the above in place, I hit an error like this.

1
/bin/sh: hoge.sh: Text file busy

What is Text file busy ?

It occurs when you try to execute a file (a shared-text file) that is currently open only for writing, or when you try to open for writing or delete a file that is a running procedure.

Given the above, my guess was:
maybe it happens because hoge.sh is being executed while chmod +x hoge.sh is still running??

Environment

  • Ubuntu 14.04.5 LTS \n \l
  • Docker version 17.05.0-ce, build 89658be
  • Base Image: ruby:2.5-alpine

Solution

Adding the sync step below resolved the problem cleanly.

1
2
3
RUN chmod +x hoge.sh \
&& sync \
&& hoge.sh

What is sync command ?

References

Working around "Text file busy" when a shell script fails to run during docker build

https://kenzo0107.github.io/en/2018/04/18/fix-text-file-busy-on-docker-build/

Author

Kenzo Tanaka

Posted on

2018-04-18

Licensed under