What command is used to stop a running Docker container?

Prepare for the Docker Foundations Test. Review essential Docker concepts with multiple choice questions, each with hints and explanations. Ace your exam!

The command to stop a running Docker container is "docker stop [container_id]". This command gracefully stops the container, allowing it to complete its current processes before shutting down. By default, it sends a SIGTERM signal to the main process in the container, which can then perform cleanup operations if necessary. If the process does not terminate within a specified timeout period, a SIGKILL signal is sent to forcibly stop the container.

This approach is preferred for stopping containers because it ensures that any ongoing operations are completed properly, which can help prevent data loss or corruption. The other choices do not represent the correct way to stop a container: "docker terminate" is not a valid Docker command, "docker kill" forcibly stops a container by sending the SIGKILL signal immediately, which does not allow for graceful shutdown, and "docker end" is also not a recognized command in Docker's CLI. Thus, "docker stop" is the appropriate command for stopping a running container in a safe and orderly manner.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy