Files
docker-cli/components/engine/daemon
Lei Jitang fe2c9ff86c Don't create source directory while the daemon is being shutdown, fix #30348
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>
Upstream-commit: 7318eba5b2f8bb4b867ca943c3229260ca98a3bc
Component: engine
2017-05-30 22:59:51 -04:00
..
2017-05-10 14:16:27 -07:00
2017-05-17 11:46:30 -07:00
2016-11-14 15:15:09 -05:00
2017-05-18 15:26:03 -07:00
2017-05-16 15:11:39 -07:00
2016-09-07 11:05:58 -07:00
2016-10-28 11:06:54 -07:00
2017-05-18 10:57:10 +08:00
2017-05-16 14:25:32 -07:00
2016-11-16 13:38:45 -08:00
2017-02-15 21:57:27 +08:00
2016-11-03 10:05:11 -07:00
2016-11-03 10:05:11 -07:00
2016-11-03 10:05:11 -07:00
2016-11-17 13:10:48 -05:00
2017-05-16 15:09:14 -07:00
2017-02-07 11:08:37 -08:00
2017-05-17 11:46:30 -07:00
2016-11-08 17:41:56 -08:00
2017-05-16 15:11:39 -07:00
2017-02-07 11:08:37 -08:00
2017-02-07 11:08:37 -08:00
2017-02-07 11:08:37 -08:00
2017-02-07 11:08:37 -08:00
2017-02-07 11:08:37 -08:00
2017-05-02 17:38:12 -04:00
2017-05-16 15:11:39 -07:00
2017-05-16 15:11:39 -07:00
2016-12-01 09:38:08 -08:00
2016-10-06 22:48:53 -03:00
2016-09-07 11:05:58 -07:00
2017-05-12 00:30:09 -04:00
2017-05-16 14:25:32 -07:00
2017-05-17 15:50:28 -07:00
2017-01-11 21:35:59 +08:00
2016-12-27 21:46:52 +08:00
2016-09-07 11:05:58 -07:00
2017-05-16 11:30:06 -07:00
2017-02-01 14:43:58 -05:00
2016-09-21 12:36:52 +02:00
2016-09-16 11:56:15 -07:00
2017-05-16 15:11:39 -07:00
2017-05-16 15:11:39 -07:00