mirror of https://github.com/docker/compose.git
Merge pull request #1827 from ndeloof/ipam
This commit is contained in:
commit
98a781f5cf
|
@ -553,7 +553,7 @@ func TestUpSecretsResources(t *testing.T) {
|
|||
secret2Value = "another_password\n"
|
||||
)
|
||||
|
||||
composefilePath := filepath.Join("aci_secrets_resources", "compose.yml")
|
||||
composefilePath := filepath.Join("aci_secrets_resources", "compose.yaml")
|
||||
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
_, _, _ = setupTestResourceGroup(t, c)
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestComposeCancel(t *testing.T) {
|
|||
s.ResetUsage()
|
||||
|
||||
c.RunDockerCmd("compose", "ls")
|
||||
buildProjectPath := "../compose/fixtures/build-infinite/docker-compose.yml"
|
||||
buildProjectPath := "../compose/fixtures/build-infinite/compose.yaml"
|
||||
|
||||
// require a separate groupID from the process running tests, in order to simulate ctrl+C from a terminal.
|
||||
// sending kill signal
|
||||
|
|
|
@ -118,7 +118,7 @@ func TestLocalComposeBuildStaticDockerfilePath(t *testing.T) {
|
|||
assert.NilError(t, err)
|
||||
defer os.RemoveAll(dir) //nolint:errcheck
|
||||
|
||||
assert.NilError(t, ioutil.WriteFile(filepath.Join(dir, "docker-compose.yml"), []byte(`services:
|
||||
assert.NilError(t, ioutil.WriteFile(filepath.Join(dir, "compose.yaml"), []byte(`services:
|
||||
service1:
|
||||
build:
|
||||
context: `+dir+`/service1
|
||||
|
@ -139,11 +139,11 @@ func TestLocalComposeBuildStaticDockerfilePath(t *testing.T) {
|
|||
RUN echo "world"
|
||||
`), 0644))
|
||||
|
||||
res := c.RunDockerCmd("compose", "-f", filepath.Join(dir, "docker-compose.yml"), "build")
|
||||
res := c.RunDockerCmd("compose", "-f", filepath.Join(dir, "compose.yaml"), "build")
|
||||
|
||||
res.Assert(t, icmd.Expected{Out: `RUN echo "hello"`})
|
||||
res.Assert(t, icmd.Expected{Out: `RUN echo "world"`})
|
||||
|
||||
c.RunDockerCmd("compose", "-f", filepath.Join(dir, "docker-compose.yml"), "down", "--rmi", "all")
|
||||
c.RunDockerCmd("compose", "-f", filepath.Join(dir, "compose.yaml"), "down", "--rmi", "all")
|
||||
})
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ func TestLocalComposeRun(t *testing.T) {
|
|||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
t.Run("compose run", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "run", "back")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "run", "back")
|
||||
lines := Lines(res.Stdout())
|
||||
assert.Equal(t, lines[len(lines)-1], "Hello there!!", res.Stdout())
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "orphan"))
|
||||
res = c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "run", "back", "echo", "Hello one more time")
|
||||
res = c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "run", "back", "echo", "Hello one more time")
|
||||
lines = Lines(res.Stdout())
|
||||
assert.Equal(t, lines[len(lines)-1], "Hello one more time", res.Stdout())
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "orphan"))
|
||||
|
@ -70,7 +70,7 @@ func TestLocalComposeRun(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("compose run --rm", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "run", "--rm", "back", "/bin/sh", "-c", "echo Hello again")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "run", "--rm", "back", "/bin/sh", "-c", "echo Hello again")
|
||||
lines := Lines(res.Stdout())
|
||||
assert.Equal(t, lines[len(lines)-1], "Hello again", res.Stdout())
|
||||
|
||||
|
@ -79,7 +79,7 @@ func TestLocalComposeRun(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("down", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "down")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "down")
|
||||
res := c.RunDockerCmd("ps", "--all")
|
||||
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
|
||||
})
|
||||
|
@ -87,7 +87,7 @@ func TestLocalComposeRun(t *testing.T) {
|
|||
t.Run("compose run --volumes", func(t *testing.T) {
|
||||
wd, err := os.Getwd()
|
||||
assert.NilError(t, err)
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "run", "--volumes", wd+":/foo", "back", "/bin/sh", "-c", "ls /foo")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "run", "--volumes", wd+":/foo", "back", "/bin/sh", "-c", "ls /foo")
|
||||
res.Assert(t, icmd.Expected{Out: "compose_run_test.go"})
|
||||
|
||||
res = c.RunDockerCmd("ps", "--all")
|
||||
|
@ -95,13 +95,13 @@ func TestLocalComposeRun(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("compose run --publish", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "run", "--publish", "8081:80", "-d", "back", "/bin/sh", "-c", "sleep 1")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "run", "--publish", "8081:80", "-d", "back", "/bin/sh", "-c", "sleep 1")
|
||||
res := c.RunDockerCmd("ps")
|
||||
assert.Assert(t, strings.Contains(res.Stdout(), "8081->80/tcp"), res.Stdout())
|
||||
})
|
||||
|
||||
t.Run("down", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yml", "down")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/run-test/compose.yaml", "down")
|
||||
res := c.RunDockerCmd("ps", "--all")
|
||||
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
|
||||
})
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestCopy(t *testing.T) {
|
|||
const projectName = "copy_e2e"
|
||||
|
||||
t.Cleanup(func() {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "--project-name", projectName, "down")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "--project-name", projectName, "down")
|
||||
|
||||
os.Remove("./fixtures/cp-test/from-default.txt") //nolint:errcheck
|
||||
os.Remove("./fixtures/cp-test/from-indexed.txt") //nolint:errcheck
|
||||
|
@ -41,7 +41,7 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("start service", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "--project-name", projectName, "up", "--scale", "nginx=5", "-d")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "--project-name", projectName, "up", "--scale", "nginx=5", "-d")
|
||||
})
|
||||
|
||||
t.Run("make sure service is running", func(t *testing.T) {
|
||||
|
@ -50,7 +50,7 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("copy to container copies the file to the first container by default", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "./fixtures/cp-test/cp-me.txt", "nginx:/tmp/default.txt")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "./fixtures/cp-test/cp-me.txt", "nginx:/tmp/default.txt")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
output := c.RunDockerCmd("exec", projectName+"_nginx_1", "cat", "/tmp/default.txt").Stdout()
|
||||
|
@ -61,7 +61,7 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("copy to container with a given index copies the file to the given container", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "--index=3", "./fixtures/cp-test/cp-me.txt", "nginx:/tmp/indexed.txt")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "--index=3", "./fixtures/cp-test/cp-me.txt", "nginx:/tmp/indexed.txt")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
output := c.RunDockerCmd("exec", projectName+"_nginx_3", "cat", "/tmp/indexed.txt").Stdout()
|
||||
|
@ -72,7 +72,7 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("copy to container with the all flag copies the file to all containers", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "--all", "./fixtures/cp-test/cp-me.txt", "nginx:/tmp/all.txt")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "--all", "./fixtures/cp-test/cp-me.txt", "nginx:/tmp/all.txt")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
output := c.RunDockerCmd("exec", projectName+"_nginx_1", "cat", "/tmp/all.txt").Stdout()
|
||||
|
@ -86,7 +86,7 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("copy from a container copies the file to the host from the first container by default", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "nginx:/tmp/default.txt", "./fixtures/cp-test/from-default.txt")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "nginx:/tmp/default.txt", "./fixtures/cp-test/from-default.txt")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
data, err := os.ReadFile("./fixtures/cp-test/from-default.txt")
|
||||
|
@ -95,7 +95,7 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("copy from a container with a given index copies the file to host", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "--index=3", "nginx:/tmp/indexed.txt", "./fixtures/cp-test/from-indexed.txt")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "--index=3", "nginx:/tmp/indexed.txt", "./fixtures/cp-test/from-indexed.txt")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
data, err := os.ReadFile("./fixtures/cp-test/from-indexed.txt")
|
||||
|
@ -104,13 +104,13 @@ func TestCopy(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("copy to and from a container also work with folder", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "./fixtures/cp-test/cp-folder", "nginx:/tmp")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "./fixtures/cp-test/cp-folder", "nginx:/tmp")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
output := c.RunDockerCmd("exec", projectName+"_nginx_1", "cat", "/tmp/cp-folder/cp-me.txt").Stdout()
|
||||
assert.Assert(t, strings.Contains(output, `hello world from folder`), output)
|
||||
|
||||
res = c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/docker-compose.yml", "-p", projectName, "cp", "nginx:/tmp/cp-folder", "./fixtures/cp-test/cp-folder2")
|
||||
res = c.RunDockerCmd("compose", "-f", "./fixtures/cp-test/compose.yaml", "-p", projectName, "cp", "nginx:/tmp/cp-folder", "./fixtures/cp-test/cp-folder2")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 0})
|
||||
|
||||
data, err := os.ReadFile("./fixtures/cp-test/cp-folder2/cp-me.txt")
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
services:
|
||||
foo:
|
||||
image: alpine
|
||||
entrypoint: ["sleep", "600"]
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 10.1.0.100 # <-- Fixed IP address
|
||||
networks:
|
||||
default:
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.1.0.0/16
|
|
@ -49,21 +49,21 @@ func TestComposeMetrics(t *testing.T) {
|
|||
t.Run("catch specific failure metrics", func(t *testing.T) {
|
||||
s.ResetUsage()
|
||||
|
||||
res := c.RunDockerOrExitError("compose", "-f", "../compose/fixtures/does-not-exist/compose.yml", "build")
|
||||
expectedErr := "compose/fixtures/does-not-exist/compose.yml: no such file or directory"
|
||||
res := c.RunDockerOrExitError("compose", "-f", "../compose/fixtures/does-not-exist/compose.yaml", "build")
|
||||
expectedErr := "compose/fixtures/does-not-exist/compose.yaml: no such file or directory"
|
||||
if runtime.GOOS == "windows" {
|
||||
expectedErr = "does-not-exist\\compose.yml: The system cannot find the path specified"
|
||||
expectedErr = "does-not-exist\\compose.yaml: The system cannot find the path specified"
|
||||
}
|
||||
res.Assert(t, icmd.Expected{ExitCode: 14, Err: expectedErr})
|
||||
res = c.RunDockerOrExitError("compose", "-f", "../compose/fixtures/wrong-composefile/compose.yml", "up", "-d")
|
||||
res = c.RunDockerOrExitError("compose", "-f", "../compose/fixtures/wrong-composefile/compose.yaml", "up", "-d")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 15, Err: "services.simple Additional property wrongField is not allowed"})
|
||||
res = c.RunDockerOrExitError("compose", "up")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 14, Err: "can't find a suitable configuration file in this directory or any parent: not found"})
|
||||
res = c.RunDockerOrExitError("compose", "up", "-f", "../compose/fixtures/wrong-composefile/compose.yml")
|
||||
res = c.RunDockerOrExitError("compose", "up", "-f", "../compose/fixtures/wrong-composefile/compose.yaml")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 16, Err: "unknown shorthand flag: 'f' in -f"})
|
||||
res = c.RunDockerOrExitError("compose", "up", "--file", "../compose/fixtures/wrong-composefile/compose.yml")
|
||||
res = c.RunDockerOrExitError("compose", "up", "--file", "../compose/fixtures/wrong-composefile/compose.yaml")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 16, Err: "unknown flag: --file"})
|
||||
res = c.RunDockerOrExitError("compose", "donw", "--file", "../compose/fixtures/wrong-composefile/compose.yml")
|
||||
res = c.RunDockerOrExitError("compose", "donw", "--file", "../compose/fixtures/wrong-composefile/compose.yaml")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 16, Err: `unknown docker command: "compose donw"`})
|
||||
res = c.RunDockerOrExitError("compose", "--file", "../compose/fixtures/wrong-composefile/build-error.yml", "build")
|
||||
res.Assert(t, icmd.Expected{ExitCode: 17, Err: `line 17: unknown instruction: WRONG`})
|
||||
|
|
|
@ -94,3 +94,26 @@ func TestNetworkAliassesAndLinks(t *testing.T) {
|
|||
_ = c.RunDockerCmd("compose", "--project-name", projectName, "down")
|
||||
})
|
||||
}
|
||||
|
||||
func TestIPAMConfig(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
const projectName = "ipam_e2e"
|
||||
|
||||
t.Run("ensure we do not reuse previous networks", func(t *testing.T) {
|
||||
c.RunDockerOrExitError("network", "rm", projectName+"_default")
|
||||
})
|
||||
|
||||
t.Run("up", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/ipam/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||
})
|
||||
|
||||
t.Run("ensure service get fixed IP assigned", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("inspect", projectName+"_foo_1", "-f", "{{ .NetworkSettings.Networks."+projectName+"_default.IPAddress }}")
|
||||
res.Assert(t, icmd.Expected{Out: "10.1.0.100"})
|
||||
})
|
||||
|
||||
t.Run("down", func(t *testing.T) {
|
||||
_ = c.RunDockerCmd("compose", "--project-name", projectName, "down")
|
||||
})
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestRestart(t *testing.T) {
|
|||
// This is just to ensure the containers do NOT exist
|
||||
c.RunDockerOrExitError("compose", "--project-name", projectName, "down")
|
||||
|
||||
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/restart-test/compose.yml", "--project-name", projectName, "up", "-d")
|
||||
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/restart-test/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||
assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-restart_restart_1 Started"), res.Combined())
|
||||
|
||||
c.WaitForCmdResult(c.NewDockerCmd("compose", "--project-name", projectName, "ps", "-a", "--format", "json"),
|
||||
|
@ -52,7 +52,7 @@ func TestRestart(t *testing.T) {
|
|||
res = c.RunDockerOrExitError("compose", "--project-name", projectName, "ps", "-a")
|
||||
testify.Regexp(t, getServiceRegx("restart", "exited"), res.Stdout())
|
||||
|
||||
_ = c.RunDockerOrExitError("compose", "-f", "./fixtures/restart-test/compose.yml", "--project-name", projectName, "restart")
|
||||
_ = c.RunDockerOrExitError("compose", "-f", "./fixtures/restart-test/compose.yaml", "--project-name", projectName, "restart")
|
||||
|
||||
// Give the same time but it must NOT exit
|
||||
time.Sleep(time.Second)
|
||||
|
|
|
@ -65,18 +65,18 @@ func TestDisplayScanMessageAfterBuild(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("display on compose build", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test-compose-build", "build")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test-compose-build", "build")
|
||||
defer c.RunDockerOrExitError("rmi", "-f", "scan-msg-test-compose-build_nginx")
|
||||
res.Assert(t, icmd.Expected{Err: "Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them"})
|
||||
})
|
||||
|
||||
t.Run("do not display on compose build with quiet flag", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test-quiet", "build", "--quiet")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test-quiet", "build", "--quiet")
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "docker scan"), res.Combined())
|
||||
res = c.RunDockerCmd("rmi", "-f", "scan-msg-test-quiet_nginx")
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "No such image"))
|
||||
|
||||
res = c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test-q", "build", "-q")
|
||||
res = c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test-q", "build", "-q")
|
||||
defer c.RunDockerOrExitError("rmi", "-f", "scan-msg-test-q_nginx")
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "docker scan"), res.Combined())
|
||||
})
|
||||
|
@ -84,14 +84,14 @@ func TestDisplayScanMessageAfterBuild(t *testing.T) {
|
|||
_ = c.RunDockerOrExitError("rmi", "scan-msg-test_nginx")
|
||||
|
||||
t.Run("display on compose up if image is built", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test", "up", "-d")
|
||||
defer c.RunDockerOrExitError("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test", "down")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test", "up", "-d")
|
||||
defer c.RunDockerOrExitError("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test", "down")
|
||||
res.Assert(t, icmd.Expected{Err: "Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them"})
|
||||
})
|
||||
|
||||
t.Run("do not display on compose up if no image built", func(t *testing.T) { // re-run the same Compose aproject
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test", "up", "-d")
|
||||
defer c.RunDockerOrExitError("compose", "-f", "./fixtures/simple-build-test/compose.yml", "-p", "scan-msg-test", "down", "--rmi", "all")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test", "up", "-d")
|
||||
defer c.RunDockerOrExitError("compose", "-f", "./fixtures/simple-build-test/compose.yaml", "-p", "scan-msg-test", "down", "--rmi", "all")
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "docker scan"), res.Combined())
|
||||
})
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ func TestStartStop(t *testing.T) {
|
|||
}
|
||||
|
||||
t.Run("Up a project", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yml", "--project-name", projectName, "up", "-d")
|
||||
res := c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||
assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop_simple_1 Started"), res.Combined())
|
||||
|
||||
res = c.RunDockerCmd("compose", "ls", "--all")
|
||||
|
@ -56,7 +56,7 @@ func TestStartStop(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("stop project", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yml", "--project-name", projectName, "stop")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "stop")
|
||||
|
||||
res := c.RunDockerCmd("compose", "ls")
|
||||
assert.Assert(t, !strings.Contains(res.Combined(), "e2e-start-stop"), res.Combined())
|
||||
|
@ -73,21 +73,21 @@ func TestStartStop(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("start project", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yml", "--project-name", projectName, "start")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "start")
|
||||
|
||||
res := c.RunDockerCmd("compose", "ls")
|
||||
testify.Regexp(t, getProjectRegx("running"), res.Stdout())
|
||||
})
|
||||
|
||||
t.Run("pause project", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yml", "--project-name", projectName, "pause")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "pause")
|
||||
|
||||
res := c.RunDockerCmd("compose", "ls", "--all")
|
||||
testify.Regexp(t, getProjectRegx("paused"), res.Stdout())
|
||||
})
|
||||
|
||||
t.Run("unpause project", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yml", "--project-name", projectName, "unpause")
|
||||
c.RunDockerCmd("compose", "-f", "./fixtures/start-stop/compose.yaml", "--project-name", projectName, "unpause")
|
||||
|
||||
res := c.RunDockerCmd("compose", "ls")
|
||||
testify.Regexp(t, getProjectRegx("running"), res.Stdout())
|
||||
|
|
|
@ -370,18 +370,24 @@ func shortIDAliasExists(containerID string, aliases ...string) bool {
|
|||
|
||||
func (s *composeService) connectContainerToNetwork(ctx context.Context, id string, netwrk string, cfg *types.ServiceNetworkConfig, links []string, aliases ...string) error {
|
||||
var (
|
||||
ipv4ddress string
|
||||
ipv4Address string
|
||||
ipv6Address string
|
||||
ipam *network.EndpointIPAMConfig
|
||||
)
|
||||
if cfg != nil {
|
||||
ipv4ddress = cfg.Ipv4Address
|
||||
ipv4Address = cfg.Ipv4Address
|
||||
ipv6Address = cfg.Ipv6Address
|
||||
ipam = &network.EndpointIPAMConfig{
|
||||
IPv4Address: ipv4Address,
|
||||
IPv6Address: ipv6Address,
|
||||
}
|
||||
}
|
||||
err := s.apiClient.NetworkConnect(ctx, netwrk, id, &network.EndpointSettings{
|
||||
Aliases: aliases,
|
||||
IPAddress: ipv4ddress,
|
||||
IPAddress: ipv4Address,
|
||||
GlobalIPv6Address: ipv6Address,
|
||||
Links: links,
|
||||
IPAMConfig: ipam,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -284,17 +284,34 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
|
|||
}
|
||||
|
||||
var networkConfig *network.NetworkingConfig
|
||||
|
||||
for _, id := range service.NetworksByPriority() {
|
||||
net := p.Networks[id]
|
||||
config := service.Networks[id]
|
||||
var ipam *network.EndpointIPAMConfig
|
||||
var (
|
||||
ipv4Address string
|
||||
ipv6Address string
|
||||
)
|
||||
if config != nil {
|
||||
ipv4Address = config.Ipv4Address
|
||||
ipv6Address = config.Ipv6Address
|
||||
ipam = &network.EndpointIPAMConfig{
|
||||
IPv4Address: ipv4Address,
|
||||
IPv6Address: ipv6Address,
|
||||
}
|
||||
}
|
||||
networkConfig = &network.NetworkingConfig{
|
||||
EndpointsConfig: map[string]*network.EndpointSettings{
|
||||
net.Name: {
|
||||
Aliases: getAliases(service, config),
|
||||
Aliases: getAliases(service, config),
|
||||
IPAddress: ipv4Address,
|
||||
IPv6Gateway: ipv6Address,
|
||||
IPAMConfig: ipam,
|
||||
},
|
||||
},
|
||||
}
|
||||
break
|
||||
break //nolint:staticcheck
|
||||
}
|
||||
|
||||
ipcmode, err := getMode(ctx, service.Name, service.Ipc)
|
||||
|
@ -931,6 +948,22 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
|
|||
if n.External.External {
|
||||
return fmt.Errorf("network %s declared as external, but could not be found", n.Name)
|
||||
}
|
||||
var ipam *network.IPAM
|
||||
if n.Ipam.Config != nil {
|
||||
var config []network.IPAMConfig
|
||||
for _, pool := range n.Ipam.Config {
|
||||
config = append(config, network.IPAMConfig{
|
||||
Subnet: pool.Subnet,
|
||||
IPRange: pool.IPRange,
|
||||
Gateway: pool.Gateway,
|
||||
AuxAddress: pool.AuxiliaryAddresses,
|
||||
})
|
||||
}
|
||||
ipam = &network.IPAM{
|
||||
Driver: n.Ipam.Driver,
|
||||
Config: config,
|
||||
}
|
||||
}
|
||||
createOpts := moby.NetworkCreate{
|
||||
// TODO NameSpace Labels
|
||||
Labels: n.Labels,
|
||||
|
@ -938,6 +971,7 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
|
|||
Options: n.DriverOpts,
|
||||
Internal: n.Internal,
|
||||
Attachable: n.Attachable,
|
||||
IPAM: ipam,
|
||||
}
|
||||
|
||||
if n.Ipam.Driver != "" || len(n.Ipam.Config) > 0 {
|
||||
|
|
|
@ -84,7 +84,7 @@ func testContainer(service string, id string) moby.Container {
|
|||
|
||||
func containerLabels(service string) map[string]string {
|
||||
workingdir, _ := filepath.Abs("testdata")
|
||||
composefile := filepath.Join(workingdir, "docker-compose.yml")
|
||||
composefile := filepath.Join(workingdir, "compose.yaml")
|
||||
return map[string]string{
|
||||
compose.ServiceLabel: service,
|
||||
compose.ConfigFilesLabel: composefile,
|
||||
|
|
Loading…
Reference in New Issue