mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #13403 from hqhq/hq_fix_ipcmode_check
Don't check running container at create time
This commit is contained in:
commit
89582f9781
3 changed files with 35 additions and 3 deletions
|
@ -114,9 +114,6 @@ func (daemon *Daemon) GenerateSecurityOpt(ipcMode runconfig.IpcMode, pidMode run
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !c.IsRunning() {
|
||||
return nil, fmt.Errorf("cannot join IPC of a non running container: %s", ipcContainer)
|
||||
}
|
||||
|
||||
return label.DupSecOpt(c.ProcessLabel), nil
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
|
@ -323,3 +324,20 @@ func (s *DockerSuite) TestCreateRM(c *check.C) {
|
|||
c.Fatalf("Failed to rm -f container:%s\n%s", out, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCreateModeIpcContainer(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
cmd := exec.Command(dockerBinary, "create", "busybox")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
cmd = exec.Command(dockerBinary, "create", fmt.Sprintf("--ipc=container:%s", id), "busybox")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatalf("Create container with ipc mode container should success with non running container: %s\n%s", out, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2660,6 +2660,23 @@ func (s *DockerSuite) TestRunModeIpcContainerNotExists(c *check.C) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunModeIpcContainerNotRunning(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
cmd := exec.Command(dockerBinary, "create", "busybox")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
cmd = exec.Command(dockerBinary, "run", fmt.Sprintf("--ipc=container:%s", id), "busybox")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err == nil {
|
||||
c.Fatalf("Run container with ipc mode container should fail with non running container: %s\n%s", out, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerNetworkMode(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
|
|
Loading…
Reference in a new issue