-1

When I run a busybox container with '-t' flag, it remains in "Running" state but without the "-t" flag, the container goes to "exit" state. How does -t flag effect container state?

$ docker run -d --name mybzy busybox -> container exits
$ docker run -dt --name mybzy1 busybox -> container keeps running
Ankit Sahay
  • 1,710
  • 8
  • 14
  • "Keep a container running" shouldn't usually be a goal on its own; if the container exits it means the main container process exited. You wouldn't usually run basic images like `busybox` or `ubuntu` on their own, but rather package an application into an image based on them, such that when the container is run, it launches the application. – David Maze Jun 27 '21 at 11:13

1 Answers1

1

The default CMD of busybox is running a shell. Running a docker container with -t means connecting it to the terminal. A shell prompts the user for input if its connected to a shell (and only if).

When running without -t, the container is not connected to your terminal, and the shell program just exits.

YoavKlein
  • 2,005
  • 9
  • 38