Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Don't create source directory while the daemon is being shutdown, fix… #48

Merged
merged 1 commit into from Jun 9, 2017

Conversation

seemethere
Copy link
Contributor

Cherry-picked from: moby/moby#33330

… #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 moby/moby#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

(cherry picked from commit 7318eba)

Signed-off-by: Eli Uriegas eli.uriegas@docker.com

Signed-off-by: Eli Uriegas eli.uriegas@docker.com

… #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 moby/moby#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>

(cherry picked from commit 7318eba)

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
@andrewhsu andrewhsu mentioned this pull request Jun 9, 2017
40 tasks
@andrewhsu andrewhsu merged commit 0cbae9b into docker:17.06 Jun 9, 2017
@andrewhsu
Copy link
Contributor

LGTM

@andrewhsu andrewhsu modified the milestone: 17.06.0 Jul 12, 2017
@seemethere seemethere deleted the cherry_pick_33330 branch August 2, 2017 21:35
andrewhsu added a commit that referenced this pull request Sep 19, 2017
…_package_building

Removes engine VERSION dependency
Upstream-commit: 3c05e03
Component: packaging
docker-jenkins pushed a commit that referenced this pull request Sep 13, 2018
[18.09] backport "daemon.ContainerLogs(): fix resource leak on follow"
Upstream-commit: 6531bac59bfd453456231511bdc3efade1fc9481
Component: engine
silvin-lubecki pushed a commit to silvin-lubecki/docker-ce that referenced this pull request Jan 30, 2020
…y_from_package_building

Removes engine VERSION dependency
Upstream-commit: 3c05e03
Component: packaging
silvin-lubecki pushed a commit to silvin-lubecki/docker-ce that referenced this pull request Jan 30, 2020
…y_from_package_building

Removes engine VERSION dependency
silvin-lubecki pushed a commit to silvin-lubecki/docker-ce that referenced this pull request Feb 3, 2020
Don't create source directory while the daemon is being shutdown, fix…
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants