QuestionQ57

VerifiedDevSecOps Pipeline-Operate and Monitor Stage

Sarah Wright, a DevSecOps engineer who has recently joined a multinational company, created a container and deployed a web application inside it. She now wants to stop this running container. Which of the following commands, run inside the container's shell, will stop the container that Sarah created?

  • A. [root@574bac18f89d /]# stop
  • B. [root@574bac18f89d /]# clear
  • C. [root@574bac18f89d /]# kill
  • D. [root@574bac18f89d /]# exit
Explanation

The prompt [root@574bac18f89d /]# indicates Sarah is operating inside the container's own shell, where the shell process is the container's main (PID 1) process. A Docker container remains running only as long as its main process continues to run; once that process terminates, the container stops. Running 'exit' at this in-container shell prompt terminates the shell process, which, being PID 1, causes the entire container to stop. The other options are not valid standalone commands in this context: 'stop' and 'kill' are Docker CLI subcommands (docker stop, docker kill) that must be run from the host with a container name/ID as an argument, not commands recognized inside the container's own shell without arguments, and 'clear' simply clears the terminal display without affecting the container's process.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!