Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/nerdctl/compose/compose_exec_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ services:
data.Labels().Set("projectName", strings.ToLower(filepath.Base(data.Temp().Dir())))

helpers.Ensure("compose", "-f", yamlPath, "up", "-d", "svc0")

// Make sure all containers are started so that /etc/hosts is consistent.
for _, index := range []string{"1", "2", "3"} {
nerdtest.EnsureContainerStarted(helpers, fmt.Sprintf("%s-svc0-%s", data.Labels().Get("projectName"), index))
}
}

testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
Expand Down
5 changes: 5 additions & 0 deletions pkg/composer/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ type ExecOptions struct {
// Exec executes a given command on a running container specified by
// `ServiceName` (and `Index` if it has multiple instances).
func (c *Composer) Exec(ctx context.Context, eo ExecOptions) error {
// Exec does not need to lock and should allow concurrency.
if err := Unlock(); err != nil {
return err
}

containers, err := c.Containers(ctx, eo.ServiceName)
if err != nil {
return fmt.Errorf("fail to get containers for service %s: %w", eo.ServiceName, err)
Expand Down