Lei Jitang
7318eba5b2
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 >
2017-05-30 22:59:51 -04:00
..
2016-03-18 13:38:32 -07:00
2017-05-19 17:10:32 -04:00
2017-05-10 14:16:27 -07:00
2017-03-29 09:00:50 +08: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
2016-12-23 13:29:58 -08:00
2017-02-23 10:16:22 +08:00
2017-05-18 23:30:00 +09:00
2016-09-13 14:21:58 -07:00
2017-03-10 10:24:33 +00:00
2016-12-07 08:47:28 +11:00
2017-05-18 00:05:13 +10:00
2017-04-12 10:33:19 +00:00
2017-04-12 10:33:19 +00:00
2017-04-12 10:33:19 +00:00
2017-03-15 13:31:41 -07:00
2017-03-15 13:31:41 -07:00
2017-05-10 17:58:57 -04:00
2017-05-16 15:11:39 -07:00
2016-09-07 11:05:58 -07:00
2016-11-07 09:06:34 -08:00
2016-11-07 09:06:34 -08:00
2017-05-10 17:59:30 -04:00
2017-01-03 19:19:27 +01:00
2016-10-28 11:06:54 -07:00
2017-05-18 10:57:10 +08:00
2017-05-10 21:16:52 -07:00
2017-05-01 18:36:53 -04:00
2017-05-11 10:08:21 -07:00
2017-05-16 14:25:32 -07:00
2017-05-16 14:25:32 -07:00
2017-05-11 10:08:21 -07:00
2017-01-30 16:23:23 +01:00
2016-11-07 09:06:34 -08:00
2017-05-16 15:11:39 -07:00
2017-05-16 14:25:32 -07:00
2017-04-10 09:13:41 -07:00
2017-01-30 16:23:23 +01:00
2017-04-12 15:45:29 -07:00
2017-04-24 21:29:47 +02:00
2016-11-16 13:38:45 -08:00
2017-05-05 16:15:22 -04:00
2016-11-10 15:51:32 -08:00
2017-02-23 10:16:22 +08:00
2017-02-02 14:00:12 -08:00
2017-04-24 21:29:47 +02:00
2017-02-15 21:57:27 +08:00
2017-02-23 10:16:22 +08:00
2017-05-05 13:45:45 -07:00
2016-05-23 16:37:12 -07:00
2017-04-12 16:54:27 -07:00
2017-05-30 22:59:51 -04: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-04-18 10:30:40 +03:00
2017-05-16 15:09:14 -07:00
2017-05-11 10:08:21 -07:00
2017-04-24 09:11:29 -07:00
2017-02-07 11:08:37 -08:00
2017-02-23 10:16:22 +08:00
2017-05-17 11:46:30 -07:00
2017-03-13 15:20:05 +11:00
2016-05-23 16:37:12 -07:00
2016-11-08 17:41:56 -08:00
2017-05-16 15:11:39 -07:00
2016-10-20 19:31:24 -07:00
2017-02-18 18:11:48 -08:00
2017-04-06 12:35:34 +02:00
2017-04-06 12:35:34 +02:00
2017-02-07 11:08:37 -08:00
2016-05-21 22:36:11 +02:00
2017-02-07 11:08:37 -08:00
2017-02-07 11:08:37 -08:00
2017-05-10 17:58:57 -04:00
2017-02-07 11:08:37 -08:00
2017-02-07 11:08:37 -08:00
2017-05-10 17:58:57 -04:00
2017-03-16 09:21:51 +08:00
2017-05-02 17:38:12 -04:00
2017-04-08 11:28:37 +02:00
2017-04-10 16:54:07 +05:30
2016-11-19 13:21:16 +01:00
2017-05-05 16:15:22 -04:00
2016-11-07 09:06:34 -08:00
2017-02-18 18:11:48 -08:00
2016-09-13 09:55:35 -04:00
2017-05-16 15:11:39 -07:00
2016-12-20 21:05:19 +08:00
2016-06-27 10:23:37 -07:00
2017-05-16 15:11:39 -07:00
2016-12-01 09:38:08 -08:00
2016-05-23 16:37:12 -07:00
2015-12-03 17:39:49 +01:00
2017-03-31 08:57:09 +00:00
2016-10-06 22:48:53 -03:00
2016-11-08 19:54:57 -08:00
2016-09-07 11:05:58 -07:00
2017-04-20 12:27:51 +01:00
2017-05-12 00:30:09 -04:00
2017-05-12 00:30:09 -04:00
2017-05-12 00:30:09 -04:00
2016-04-06 14:03:05 -07:00
2016-05-23 16:37:12 -07:00
2016-10-24 00:20:36 -07:00
2017-05-30 22:59:51 -04:00
2017-05-11 12:31:53 -04:00
2017-01-17 08:26:05 +00:00
2017-05-17 15:50:28 -07:00
2017-05-11 10:08:21 -07:00
2016-11-07 09:06:34 -08:00
2017-05-16 14:25:32 -07:00
2016-03-18 13:38:32 -07:00
2017-05-17 15:50:28 -07:00
2017-05-16 14:36:36 -07:00
2017-05-16 14:36:36 -07:00
2017-01-11 21:35:59 +08:00
2016-03-18 13:38:32 -07:00
2016-10-28 07:56:05 -04:00
2016-12-27 21:46:52 +08:00
2016-09-07 11:05:58 -07:00
2016-08-17 09:38:34 -07:00
2017-05-05 13:45:45 -07:00
2016-07-08 17:26:42 -07:00
2016-11-09 14:27:43 -05:00
2017-05-16 11:30:06 -07:00
2017-05-16 11:30:06 -07:00
2017-05-11 10:08:21 -07:00
2017-04-24 21:29:47 +02:00
2015-11-12 15:48:41 -08:00
2017-01-12 20:36:22 +01:00
2017-02-28 20:03:43 -08:00
2017-02-01 14:43:58 -05:00
2017-01-04 18:18:30 +01:00
2016-09-21 12:36:52 +02:00
2016-09-16 11:56:15 -07:00
2017-02-09 09:46:59 +08:00
2017-05-16 15:11:39 -07:00
2017-03-10 02:50:21 +00:00
2017-03-10 02:50:21 +00:00
2017-01-03 11:47:47 -05:00
2016-08-29 10:16:18 +08:00
2017-04-06 15:40:12 -07:00
2016-09-07 11:05:58 -07:00
2016-09-07 11:05:58 -07:00
2017-05-03 10:59:38 -04:00
2015-12-16 16:50:25 +01:00
2017-05-11 12:31:53 -04:00
2017-05-30 22:59:51 -04:00
2017-05-30 22:59:51 -04:00
2017-05-15 15:49:07 -04:00
2017-05-16 15:11:39 -07:00
2017-01-30 10:59:19 -05:00