Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create source directory while the daemon is being shutdown, fix #30348 #33330

Merged
merged 1 commit into from Jun 7, 2017

Commits on May 31, 2017

  1. Don't create source directory while the daemon is being shutdown, fix m…

    …oby#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#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>
    coolljt0725 committed May 31, 2017
    Copy the full SHA
    7318eba View commit details
    Browse the repository at this point in the history