Attaching container logs

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2020-12-17 12:43:39 +01:00
parent db73c928f3
commit 3714ab7d41
2 changed files with 5 additions and 3 deletions

View File

@ -120,6 +120,7 @@ func (s *composeService) getContainerStreams(ctx context.Context, container moby
Stdin: true,
Stdout: true,
Stderr: true,
Logs: true,
})
if err != nil {
return nil, nil, err

View File

@ -108,7 +108,8 @@ func TestLocalComposeRun(t *testing.T) {
t.Run("compose run", func(t *testing.T) {
res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "back")
res.Assert(t, icmd.Expected{Out: "Hello there!!"})
lines := Lines(res.Stdout())
assert.Equal(t, lines[len(lines)-1], "Hello there!!", res.Stdout())
})
t.Run("check run container exited", func(t *testing.T) {
@ -142,7 +143,7 @@ func TestLocalComposeRun(t *testing.T) {
t.Run("compose run --rm", func(t *testing.T) {
res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "--rm", "back", "/bin/sh", "-c", "echo Hello again")
lines := Lines(res.Stdout())
assert.Equal(t, lines[len(lines)-1], "Hello again")
assert.Equal(t, lines[len(lines)-1], "Hello again", res.Stdout())
})
t.Run("check run container removed", func(t *testing.T) {
@ -151,7 +152,7 @@ func TestLocalComposeRun(t *testing.T) {
})
t.Run("down", func(t *testing.T) {
_ = c.RunDockerCmd("compose", "down", "-f", "./fixtures/run-test/docker-compose.yml")
c.RunDockerCmd("compose", "down", "-f", "./fixtures/run-test/docker-compose.yml")
res := c.RunDockerCmd("ps", "--all")
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
})