7318eba5b2
If a container mount the socket the daemon is listening on into container while the daemon is being shutdown, the socket will not exist on the host, then daemon will assume it's a directory and create it on the host, this will cause the daemon can't start next time. fix issue https://github.com/moby/moby/issues/30348 To reproduce this issue, you can add following code ``` --- a/daemon/oci_linux.go +++ b/daemon/oci_linux.go @@ -8,6 +8,7 @@ import ( "sort" "strconv" "strings" + "time" "github.com/Sirupsen/logrus" "github.com/docker/docker/container" @@ -666,7 +667,8 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e if err := daemon.setupIpcDirs(c); err != nil { return nil, err } - + fmt.Printf("===please stop the daemon===\n") + time.Sleep(time.Second * 2) ms, err := daemon.setupMounts(c) if err != nil { return nil, err ``` step1 run a container which has `--restart always` and `-v /var/run/docker.sock:/sock` ``` $ docker run -ti --restart always -v /var/run/docker.sock:/sock busybox / # ``` step2 exit the the container ``` / # exit ``` and kill the daemon when you see ``` ===please stop the daemon=== ``` in the daemon log The daemon can't restart again and fail with `can't create unix socket /var/run/docker.sock: is a directory`. Signed-off-by: Lei Jitang <leijitang@huawei.com> |
||
---|---|---|
.. | ||
hack | ||
config.go | ||
config_common_unix.go | ||
config_experimental.go | ||
config_solaris.go | ||
config_unix.go | ||
config_unix_test.go | ||
config_windows.go | ||
daemon.go | ||
daemon_freebsd.go | ||
daemon_linux.go | ||
daemon_solaris.go | ||
daemon_test.go | ||
daemon_unix.go | ||
daemon_unix_test.go | ||
daemon_windows.go | ||
docker.go | ||
docker_windows.go | ||
metrics.go | ||
README.md | ||
service_unsupported.go | ||
service_windows.go |
docker.go contains Docker daemon's main function.
This file provides first line CLI argument parsing and environment variable setting.