HiveBrain v1.2.0
Get Started
← Back to all entries
patterndockerMinor

Is it allowed to remove mounted directory from inside Docker container?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
directorymountedallowedcontainerdockerremovefrominside

Problem

I have a container which is based on tomcat image and I have mounted 'webapps' folder to hosted machine directory '/app/webapps'. Now for some updations I want to remove this webapps folder from inside the container but when I execute command: rm -rf webapps below error is produced:


rm: cannot remove 'webapps': Device or resource busy

So I want to know is it possible to remove mounted directory by executing a Linux command from inside the container or not?

Solution

No, you sadly can't remove a volume that is in use by a container which is stated under 'Extended Description' here: https://docs.docker.com/engine/reference/commandline/volume_rm/

However, I'd suggest using docker for its strength and restarting the docker container after updating the directory externally.

Context

StackExchange DevOps Q#6711, answer score: 4

Revisions (0)

No revisions yet.