New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container with NFS volume does not come up on system restart with restart always policy #25584
Comments
Are you seeing an error when trying to start the container? |
Update: It seems like there definitely is a race condition. NFS kicks off, but then backgrounds the "mount", and docker ignores the After because the process has kicked off. Removing "bg" from the fstab NFS options seems to have helped. Specifically, having: What we had before was: |
What does your systemd unit file look like? |
The override looks like this:
And we added:
They key part there is "After=nfs.mount" --> assuming this should probably be added by default, since if there's no /etc/fstab mount, it will just skip over it. The default that we are overriding by appending the Unit is:
And has:
|
Docker does not care about nfs here. All it does is try to start the container with the host path mounted in (and if the hostpath doesn't exist it would create it). Did you check the container logs? |
@cpuguy83 - Yea, it's failing just because the config (in this case, our test is an openvpn container and it's looking for the server.conf + certs). But I think we figured out the issue -- it was NFS backgrounding and tricking docker into thinking that it "ran". So the summary is in two parts: |
So it sounds like we can close this? |
@cpuguy83 yea, but hopefully you can submit a request to add the parameter to the default Unit file, so that it looks like this: It will not impact people who are not using nfs, as it will just skip over it. But this way, for everyone using NFS, it will actually work. |
@ventz I'm not sure this is a good option to have in the config file for everyone using Docker and is easy enough to add the customization. |
@cpuguy83 ok -- maybe potentially just adding a section to the Docker docs then? I updated the top here with the solution so that hopefully others who run into this can find the answer quickly for now. |
This is an old issue. I will close it as stale. |
UPDATE / SOLUTION FOR ANYONE HAVING THIS PROBLEM
1.) Make sure your NFS mount in /etc/fstab does NOT have the "bg" background field
and
2.) Create: /etc/systemd/system/docker.service.d/override.conf
with:
and then
systemctl daemon-reload
and then reboot.
This is needed until docker adds "After=nfs.mount" to the default docker Unit section.
^^^ UPDATE / SOLUTION FOR ANYONE HAVING THIS PROBLEM ^^^
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Physical Dell m610 blade on a m1000 chassis.
Running Ubuntu 16.04 LTS
Steps to reproduce the issue:
Let's assume "/nfs/container01" exists and in that folder there is a "service01" dir.
docker run -d --restart=always --net=somenetwork --ip=10.0.0.101 -v /nfs/container01/service01:/etc/service01 alpine
note: same case with Ubuntu, and other systems.
The container will NOT start on reboot.
Same result if you shutdown the container.
Describe the results you received:
Container does NOT start on reboot, even though it exists and the NFS volume is available.
Describe the results you expected:
Container should start. Local containers (that mount "local" volumes do start)
Additional information you deem important (e.g. issue happens only occasionally):
Tried creating an override file for systemd:
vim /etc/systemd/system/docker.service.d/override.conf
With:
and later also tried instead with:
and then also tried:
In both cases after that with
systemctl daemon-reload
and then reboot. Same result, no difference.My assumption is that there is a race condition between docker and NFS. Once the physical host has rebooted, if I start the the container manually, it works. It just won't start automatically.
The text was updated successfully, but these errors were encountered: