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

Docker re-starting containers before drive-sharing is done

Open KekSfabrik opened this issue 10 years ago • 12 comments

Expected behavior

Containers with a restart olicy like restart=always or restart=unless-stopped are started after a system reboot and re-mount the volumes they have been started with

Actual behavior

After a system reboot containers previously launched with a restart policy are restarted before the daemon was able to access the shared folder so none of the persisted files are present (daemon log reflects this)

Information

  • Windows 10 Pro
  • Docker 1.12.0-beta21 (build 5971) 9cd1dc2

Steps to reproduce the behavior

  1. start a container docker run -dit --name redis -p 6379:6379 -v C:\some\path:/data --restart=always redis
  2. write some things to redis (docker exec redis redis-cli PUT <key> <value>), do a docker exec redis redis-cli BGSAVE to make sure those are persisted
  3. check in C:\some\path that the redis.rdb file was actually written
  4. reboot PC
  5. be suprised that redis is running but the persisted file wasn't loaded and redis is empty (docker exec redis redis-cli info) -- stopping and restarting the container does work

KekSfabrik avatar Sep 05 '16 13:09 KekSfabrik

@KekSfabrik thanks for the detailed report and (simple repro)! There is indeed a ordering/race issue: The docker daemon starts before we trigger the mount.

/cc @dgageot

rn avatar Sep 05 '16 15:09 rn

@rneugeba That will not be an easy one to fix will it?

dgageot avatar Sep 05 '16 15:09 dgageot

@dgageot nope...I think it's a reasonable thing to do, but currently can't think of an easy fix

rn avatar Sep 05 '16 15:09 rn

@workmonitored reported the same issue on #472.

rn avatar Feb 08 '17 14:02 rn

The only way I can think of it would require at least to keep the credential in clear text in memory (like in datakit and exposed to moby trough 9pmount). Feels meehh! to me.

simonferquel avatar Feb 08 '17 14:02 simonferquel

So basically the docker daemon starts before I login and does not have access to the directory I have access to and then when I login and stop and start the docker image, it has credentials and it can see the files.

In my case, I have a windows domain account and local account with admin rights. When I pull up the procexp64 from sysinternals, it looks like it is running under user id with local account with admin rights. I have verified that it has access to the directory and it can see the files and write to them. So that does not explain to me why the first mount fails and the second succeeds.

One little caveat is the mount directory is also a sync point for the google drive even though it is on my local system

However I have problems mentioned with redis image (not being able to find the dump) and so have thought I was doing something wrong till it started happening with the gogs/gogs image and I decided to stop and start and it started working.

workmonitored avatar Feb 08 '17 18:02 workmonitored

@junhwong reported the same issue on #524

rn avatar Mar 03 '17 21:03 rn

Is this limited to Windows? What is preventing the mounts to be performed before the daemon completely starts?

trajano avatar Sep 04 '17 18:09 trajano

What is preventing the mounts to be performed before the daemon completely starts?

The code the accomplishes the mount itself runs as a container so the daemon has to be up before the mount can be made.

friism avatar Sep 05 '17 00:09 friism

@friism kinda wish they had depends_on_healthcheck which would wait for HEALTHCHECK to pass before continuing.

trajano avatar Sep 05 '17 02:09 trajano

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

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

If this issue is safe to close now please do so.

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

docker-robott avatar Mar 27 '18 10:03 docker-robott

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 Jun 18 '20 03:06 docker-robott