for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Docker deletes all my files on WSL2 where containers have linked volumes

Open brunoclima opened this issue 6 years ago • 17 comments

  • [x] I have tried with the latest version of my channel (Stable or Edge)
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: 9E4AB818-5C66-42CF-BF17-3FC09FEE62FB/20200909124748

Expected behavior

Docker starts up without deleting my files.

Actual behavior

Docker deletes all files where containers have linked volumes. Even the stopped containers.

Information

I'm using WSL2 Ubuntu-20.04 with distro integration enabled. I have another projects on the same directory. But only the ones within containers were gone, so it is not a problem with WSL2. Containers are not deleted. Only files.

Not sure if its reproducible. I just updated docker and files were gone. Then the next day I downloaded files again but when docker starts it wipes everything again. I use many different official images and every single folder was empty.

The problem is new. It happened since the last update.

  • Windows Version: 10.0.19042 Compilation 19042
  • Docker Desktop Version: v19.03.13-beta2
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: Running on WSL2 Ubuntu-20.04 with distro integration enabled.

Steps to reproduce the behavior

  1. Create a container with a linked volume.
  2. Start Docker.

brunoclima avatar Sep 09 '20 13:09 brunoclima

Can you provide a set of commands so that we can try to reproduce ?

simonferquel avatar Sep 09 '20 13:09 simonferquel

Just happened to me. Last thing I did was update to latest version of experimental channel. Diagnostics ID: B9224D7C-4383-4019-8E2D-5BF4E9766816/20200909134152.

Also I'm unable to delete the directory that was mounted in the container. Linux says "device or resource busy".

haggen avatar Sep 09 '20 13:09 haggen

Same to me. Here is my Diagnostic ID: 9021F2BB-5133-43EF-A424-4EB7D304FC17/20200909131941

AbraaoAlves avatar Sep 09 '20 13:09 AbraaoAlves

Can you provide a set of commands so that we can try to reproduce ?

npx create-react-app my-app
cd my-app

Create a docker-compose.yml

version: "3"

services:
  web:
    image: node:lts-alpine
    working_dir: /app
    volumes:
      - .:/app

Create container with docker-compose up -d. Restart Docker Desktop.

brunoclima avatar Sep 09 '20 13:09 brunoclima

Thanks I can reproduce locally. Sorry about the mess.

simonferquel avatar Sep 09 '20 14:09 simonferquel

This is happening to my mounted volumes with docker edge latest release too on windows 10 with WSL2.

Whenever i start a container , and reboot the machine / restart docker desktop my mounted files are removed from the wsl host and marked as deleted.

my command to run a affected docker container

docker run
--name piranha-mvc
--env-file $SRCPATH/.devcontainer/development.env
--mount type=bind,source="/usr/local/lib/node_modules",target=/usr/local/lib/node_modules
--mount type=bind,source="$SRCPATH",target=$WORKSPACEPATH
--mount type=bind,source="$SRCPATH/app",target=/root/app
--mount type=bind,source="$SRCPATH/certs",target=/root/certs
piranha-mvc:latest \

all files in the mounted source directories are deleted.

Is this issue only with the docker desktop edge channel release?

I am currently trying to recover files:

Using testdisk the deleted files are visible in the vhd of wsl distro but i am unable to recover subdirectories with testdisk. It reports them as corrupted.

Now trying to recover files with diskinternals linux recovery software.

FRANK3NST31N avatar Sep 09 '20 14:09 FRANK3NST31N

I don't know if this docker integration was responsible, but someone here have been global git config info removed too?

AbraaoAlves avatar Sep 09 '20 14:09 AbraaoAlves

We are pulling 2.3.6.1 back, sorry for this mess, it is totally on me. 2.3.6.2 coming very soon (tonight or tomorrow morning).

simonferquel avatar Sep 09 '20 15:09 simonferquel

@simonferquel Is there a way to recover the files? I might have lost some git stashes and working branches when it deleted my .git directory that I would love to have back. :/

haggen avatar Sep 09 '20 18:09 haggen

I think I got affected by this, but I'm not sure, how can I be sure it was this problem?

ernestorocha avatar Sep 09 '20 19:09 ernestorocha

I think I got affected to this, but I'm not sure, how can I be sure it was this problem?

@ernestorocha

Can you provide a set of commands so that we can try to reproduce ?

npx create-react-app my-app
cd my-app

Create a docker-compose.yml

version: "3"

services:
  web:
    image: node:lts-alpine
    working_dir: /app
    volumes:
      - .:/app

Create container with docker-compose up -d. Restart Docker Desktop.

brunoclima avatar Sep 09 '20 19:09 brunoclima

I just confirmed, it was this problem that wiped out my folder.

Just created a random file inside the folder and restarted docker desktop. BOOM, file is gone.

I had a docker compose for this service that I used a long time ago and I even didn't remember that.

So, yeah, I can confirm the issue. And as stated by you, nothing needs to run, only the fact the is listed on Docker Desktop is enough to get the files deleted.

ernestorocha avatar Sep 09 '20 20:09 ernestorocha

Same here. Luckily, I was able to get the files back using intellij's local history!

F21 avatar Sep 09 '20 23:09 F21

\(〇_o)/

(╯°□°)╯︵ ┻━┻

╰(‵□′)╯

Does anyone have a good excuse to push back a few due dates? I'll probably go with Docker ate my git 👁👄👁

coverrt avatar Sep 09 '20 23:09 coverrt

Same here :( Luckily I do export my WSL2 machine every evening so damage was not too big but I just wondered what's going on till I found this thread. wsl --export made my day :)

yoobeedoobee avatar Sep 10 '20 07:09 yoobeedoobee

I can confirm that the new update is not deleting the files anymore, but 2 strange behaviors are still there:

  • I can't remove the service created in the past through docker-compose on Docker Desktop. The "delete" action (trash can icon) does nothing. No output, no error message.
  • Trying to remove folder (volume) that got wiped out while running Docker Desktop still returns Device or resource busy

ernestorocha avatar Sep 10 '20 10:09 ernestorocha

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked

docker-robott avatar Oct 10 '20 03:10 docker-robott