desktop-linux icon indicating copy to clipboard operation
desktop-linux copied to clipboard

cannot unmount a folder, if that was bind-mounted into a container (target is busy - held by virtiofsd)

Open user706 opened this issue 3 years ago • 4 comments
trafficstars

  • [x] I have tried with the latest version of Docker Desktop
  • [ ] I have tried disabling enabled experimental features
  • [ ] I have uploaded Diagnostics
  • Diagnostics ID:

Expected behavior

Host                         Docker Container
======================     =====================
/tmp      target1/          container:/target1
  |        ^   |                  ^
  \        |   \                  |
   --------     ------------------
  bind-mount            bind-mount
   in host              into container

The expected behaviour is
once the container is finished, it must be possible to cleanly unmount target1 from the host.

Actual behavior

But it is not possible to cleanly unmount target from the host (once the container is finished):
umount: /hostpath/to/problemDockerUnmount/target1: target is busy.

virtiofsd is still holding on somehow:

sudo fuser -v /hostpath/to/problemDockerUnmount/target1

shows

                     USER        PID ACCESS COMMAND
/hostpath/to/problemDockerUnmount/target1:
                     root     kernel mount /hostpath/to/problemDockerUnmount/target1
                     hero      11969 f.... virtiofsd

and

sudo lsof     target1

shows

COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
virtiofsd 11969 hero     28u   DIR  253,1    20480 24510465 target1

Snippet:

TARGET=target1
mkdir -p $TARGET

# mount something in host
sudo mount --bind /tmp $TARGET

# bind-mount that further... into the container
docker run --rm --name $CONTAINER_NAME --mount type=bind,source="$(readlink -e $TARGET)",target=/target1,readonly -it "$IMAGE_NAME" /bin/bash -c 'ls -l /target1'

# container is now finished!

# unmount in host
sudo umount    $TARGET    ## Error: umount: /path/to/problemDockerUnmount/target1: target is busy.

I need to actually click "Quit Docker Desktop". Only once it is off completely, does the unmount (sudo umount $TARGET) succeed.

Information

  • Linux distro: Ubuntu
  • Distro version: 22.04
  • Docker Desktop Version: v4.13.0 (docker --version shows Docker version 20.10.21, build baeda1f)

Steps to reproduce the behavior

To reproduce, please clone this repo problemDockerUnmount and run ./go.sh

user706 avatar Oct 26 '22 14:10 user706

hi @user706, thanks for filing this issue and sorry for the inconvenience. Currently Docker Desktop will launch a virtiofsd instance for each directory shared with Docker Desktop VM, which has to happen before the VM is launched. I suppose that is the reason you are unable to unmount the directory you want without quitting Desktop (I suspect a restart would work as well, since that will relaunch the VM and virtiofsd). We'll investigate a better way to handle this.

p1-0tr avatar Oct 28 '22 09:10 p1-0tr

ok, thank for the information. Would be nice if you find a way of improving it. (For now... I'm running docker engine instead, and it works)

user706 avatar Oct 28 '22 11:10 user706

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

docker-robott avatar Feb 28 '23 01:02 docker-robott

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

docker-robot[bot] avatar Jun 23 '23 01:06 docker-robot[bot]