mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix docker exec -u
issue after docker daemon restart
This fix tries to address the issue raised in 29342 where
`docker exec -u` after docker daemon restart returns an error:
```
unable to find user test: no matching entries in passwd file
```
The reason was that `container.BaseFS` is not present after restart.
This fix adds the `daemon.Mount` during the restore to bring up the
`container.BaseFS`.
An integration test has been added to cover the changes.
This fix fixes 29342.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
(cherry picked from commit 7feb2a17e4
)
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
c9a557765e
commit
a80251e8cd
2 changed files with 29 additions and 0 deletions
|
@ -149,6 +149,10 @@ func (daemon *Daemon) restore() error {
|
|||
continue
|
||||
}
|
||||
container.RWLayer = rwlayer
|
||||
if err := daemon.Mount(container); err != nil {
|
||||
logrus.Errorf("Failed to mount container %v: %v", id, err)
|
||||
continue
|
||||
}
|
||||
logrus.Debugf("Loaded container %v", container.ID)
|
||||
|
||||
containers[container.ID] = container
|
||||
|
|
|
@ -2927,3 +2927,28 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *check.C)
|
|||
content, _ := ioutil.ReadFile(s.d.logFile.Name())
|
||||
c.Assert(string(content), checker.Contains, expectedMessage)
|
||||
}
|
||||
|
||||
// Test case for 29342
|
||||
func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
s.d.StartWithBusybox("--live-restore")
|
||||
|
||||
out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && top")
|
||||
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
||||
|
||||
waitRun("top")
|
||||
|
||||
out1, err := s.d.Cmd("exec", "-u", "test", "top", "id")
|
||||
// uid=100(test) gid=101(test) groups=101(test)
|
||||
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out1))
|
||||
|
||||
// restart daemon.
|
||||
s.d.Restart("--live-restore")
|
||||
|
||||
out2, err := s.d.Cmd("exec", "-u", "test", "top", "id")
|
||||
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out2))
|
||||
c.Assert(out1, check.Equals, out2, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2))
|
||||
|
||||
out, err = s.d.Cmd("stop", "top")
|
||||
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue