JoeB
JoeB

Reputation: 251

cannot remove 'folder': Device or resource busy

I create centos with docker and After I start the container, I would remove a directory where there are other two directories.

and I do :

rm -f -r ./folder

and I obtain:

cannot remove 'folder': Device or resource busy

Anyone can help me?

Upvotes: 13

Views: 40041

Answers (5)

Hamlet Kraskian
Hamlet Kraskian

Reputation: 801

1- ps aux | grep docker.

From there you can get all processes containing "docker" word

2- #kill <process_id>

3- #rm -rf <thedir>

Upvotes: 0

amarachi
amarachi

Reputation: 43

This happened to me, until I closed the code editor VS-Code. Somehow VS code had the folder open so it could not close until the editor was closed.

Upvotes: 3

Manifest Man
Manifest Man

Reputation: 905

Another pretty much simple answer is following:

1. Close all your terminal windows (bash, shell, etc...)

2. Start a new terminal

3. Execute your command again e.g.:

rm -f -r ./folder

4. done

Hopefully it helps others!

Upvotes: 7

Kevin Ding
Kevin Ding

Reputation: 814

if you use windows, it's com.docker.backend.exe , terminate it, everything will ok.

If you know the reason why backend cause this problem, tell me.

Upvotes: 3

Bill Cheng
Bill Cheng

Reputation: 742

Maybe you have that folder opened up somewhere. Try lsof to find the opened folder and then sudo kill <pid>. Afterwards, I believe you can remove the folder from there.

Upvotes: 0

Related Questions