docker/cli · error
you cannot start and attach multiple containers at once
Error message
you cannot start and attach multiple containers at once
What it means
Raised in RunStart for `docker start` when attach mode is requested (--attach/-a or --interactive/-i) with more than one container argument. Attaching hijacks a single bidirectional stream to one container's stdio and wires up TTY/signal forwarding, which cannot be multiplexed across containers, so the CLI enforces exactly one container in this mode.
Source
Thrown at cli/command/container/start.go:86
//nolint:gocyclo
func RunStart(ctx context.Context, dockerCli command.Cli, opts *StartOptions) error {
ctx, cancelFun := context.WithCancel(ctx)
defer cancelFun()
detachKeys := opts.DetachKeys
if detachKeys == "" {
detachKeys = dockerCli.ConfigFile().DetachKeys
}
if err := validateDetachKeys(detachKeys); err != nil {
return err
}
switch {
case opts.Attach || opts.OpenStdin:
// We're going to attach to a container.
// 1. Ensure we only have one container.
if len(opts.Containers) > 1 {
return errors.New("you cannot start and attach multiple containers at once")
}
// 2. Attach to the container.
ctr := opts.Containers[0]
c, err := dockerCli.Client().ContainerInspect(ctx, ctr, client.ContainerInspectOptions{})
if err != nil {
return err
}
// We always use c.ID instead of container to maintain consistency during `docker start`
if !c.Container.Config.Tty {
sigc := notifyAllSignals()
bgCtx := context.WithoutCancel(ctx)
go ForwardAllSignals(bgCtx, dockerCli.Client(), c.Container.ID, sigc)
defer signal.StopCatch(sigc)
}
options := client.ContainerAttachOptions{View on GitHub (pinned to e9452d6e78)
Solutions
- Drop -a/-i to start all containers detached: docker start ctr1 ctr2, then follow one with docker logs -f
- Start and attach to just one container per command: docker start -a ctr1
- To watch output of several containers, start them detached and use docker logs -f per container (or docker compose up)
Example fix
# before docker start -a web db cache # after docker start web db cache docker logs -f web
When it happens
Trigger: `docker start -a ctr1 ctr2`, `docker start -i ctr1 ctr2 ctr3` — opts.Attach or opts.OpenStdin true with len(opts.Containers) > 1. Without -a/-i, starting multiple containers at once is fine.
Common situations: Scripts that expand a list of containers into `docker start -a $list`; users adding -a out of habit when bulk-restarting stopped containers; confusion with docker-compose which can stream logs from many services at once.
Related errors
- valid streams are STDIN, STDOUT and STDERR
- cannot attach to a stopped container, start it first
- cannot attach to a paused container, unpause it first
- cannot attach to a restarting container, wait until it is ru
- destination can not be empty
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/d3b55a67dd894a34.json.
Report an issue: GitHub.