Docker re-starting containers before drive-sharing is done
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
- start a container
docker run -dit --name redis -p 6379:6379 -v C:\some\path:/data --restart=always redis - write some things to redis (
docker exec redis redis-cli PUT <key> <value>), do adocker exec redis redis-cli BGSAVEto make sure those are persisted - check in C:\some\path that the redis.rdb file was actually written
- reboot PC
- 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 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
@rneugeba That will not be an easy one to fix will it?
@dgageot nope...I think it's a reasonable thing to do, but currently can't think of an easy fix
@workmonitored reported the same issue on #472.
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.
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.
@junhwong reported the same issue on #524
Is this limited to Windows? What is preventing the mounts to be performed before the daemon completely starts?
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 kinda wish they had depends_on_healthcheck which would wait for HEALTHCHECK to pass before continuing.
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
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