Skip to content
5 changes: 3 additions & 2 deletions cmd/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ func RootCommand(dockerCli command.Cli, backendOptions *BackendOptions) *cobra.C
display.Mode = display.ModeTTY
}

detached, _ := cmd.Flags().GetBool("detach")
var ep api.EventProcessor
switch opts.Progress {
case "", display.ModeAuto:
Expand All @@ -513,7 +514,7 @@ func RootCommand(dockerCli command.Cli, backendOptions *BackendOptions) *cobra.C
display.Mode = display.ModePlain
ep = display.Plain(dockerCli.Err())
case dockerCli.Out().IsTerminal():
ep = display.Full(dockerCli.Err(), stdinfo(dockerCli))
ep = display.Full(dockerCli.Err(), stdinfo(dockerCli), detached)
default:
ep = display.Plain(dockerCli.Err())
}
Expand All @@ -522,7 +523,7 @@ func RootCommand(dockerCli command.Cli, backendOptions *BackendOptions) *cobra.C
return fmt.Errorf("can't use --progress tty while ANSI support is disabled")
}
display.Mode = display.ModeTTY
ep = display.Full(dockerCli.Err(), stdinfo(dockerCli))
ep = display.Full(dockerCli.Err(), stdinfo(dockerCli), detached)

case display.ModePlain:
if ansi == "always" {
Expand Down
16 changes: 9 additions & 7 deletions cmd/display/tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ import (

// Full creates an EventProcessor that render advanced UI within a terminal.
// On Start, TUI lists task with a progress timer
func Full(out io.Writer, info io.Writer) api.EventProcessor {
func Full(out io.Writer, info io.Writer, detached bool) api.EventProcessor {
return &ttyWriter{
out: out,
info: info,
tasks: map[string]*task{},
done: make(chan bool),
mtx: &sync.Mutex{},
out: out,
info: info,
tasks: map[string]*task{},
done: make(chan bool),
mtx: &sync.Mutex{},
detached: detached,
}
}

Expand All @@ -60,6 +61,7 @@ type ttyWriter struct {
ticker *time.Ticker
suspended bool
info io.Writer
detached bool
}

type task struct {
Expand Down Expand Up @@ -190,7 +192,7 @@ func (w *ttyWriter) On(events ...api.Resource) {
continue
}

if w.operation != "start" && (e.Text == api.StatusStarted || e.Text == api.StatusStarting) {
if w.operation != "start" && (e.Text == api.StatusStarted || e.Text == api.StatusStarting) && !w.detached {
// skip those events to avoid mix with container logs
continue
}
Expand Down
21 changes: 21 additions & 0 deletions pkg/e2e/networks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,24 @@ func TestNetworkRecreate(t *testing.T) {
Container network_recreate-web-1 Starting
Container network_recreate-web-1 Started`})
}

func TestNetworkIPAMChangeReportsStarted(t *testing.T) {
c := NewCLI(t)
const projectName = "ipam-change-e2e"
defer c.cleanupWithDown(t, projectName)

// Start with default subnet
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/network-test/compose.subnet.yaml", "--project-name", projectName, "up", "-d")
res.Assert(t, icmd.Success)

// Change SUBNET and run up again; progress in plain should print container events
cmd := c.NewCmdWithEnv([]string{"SUBNET=192.168.0.0/16"}, "docker", "compose", "-f", "./fixtures/network-test/compose.subnet.yaml", "--project-name", projectName, "--progress=plain", "up", "-d")
res = icmd.RunCmd(cmd)
res.Assert(t, icmd.Success)

out := res.Combined()
// We expect to see the container transition reported: Stopped then Started (or Recreated)
if !strings.Contains(out, "Stopped") || !(strings.Contains(out, "Started") || strings.Contains(out, "Recreated")) {
t.Fatalf("expected Stopped then Started/Recreated in output, got:\n%s", out)
}
}