Which command-line option is used to run a Docker container in the background (detached mode)?
The -d flag detaches the container, running it in the background and returning the container ID to the shell. This satisfies the detached-mode requirement, unlike -it which attaches an interactive TTY to the foreground process.
Why this answer
The -d (or --detach) flag runs a Docker container in the background, returning the container ID and freeing the terminal. This is the standard way to start long-running services like web servers without blocking the shell. Combined with -p for port mapping and --name for identification, it is the canonical detached-mode invocation.
Exam trap
The trap is that -i and -t are commonly used together for interactive containers, so candidates may confuse them with detachment; the exam expects recognition that only -d (--detach) backgrounds the container.
How to eliminate wrong answers
Option A is wrong because -i keeps STDIN open for interactive input; it does not detach the container. Option B is wrong because --bg is not a Docker flag; the correct long form is --detach. Option D is wrong because -b is not a valid Docker run flag for background mode (it was historically used for bridge networking in some contexts, but not detachment).
Option E is wrong because -t allocates a pseudo-TTY; it is often paired with -i for interactive sessions but does not detach.