What is the purpose of the -d option in the command 'docker run -d --rm -P nginx'?

Study for the Kubernetes Cloud Native Associate (KCNA) Certification. Prepare with flashcards and multiple choice questions. Ensure success with detailed explanations. Ready for your exam!

Multiple Choice

What is the purpose of the -d option in the command 'docker run -d --rm -P nginx'?

Explanation:
The -d option runs the container in detached mode, meaning it starts in the background and is detached from your current terminal session. This lets the container keep running while you continue to use the shell, instead of tying up the terminal with the container’s foreground output. When you run in detached mode, you won’t see the container’s logs in real time in the terminal, but you can still view them later with commands like docker logs <container-id>. In the given command, -d works with --rm so the container will run in the background and be automatically removed when it stops, while -P maps ports. If you need interactive work or live terminal output, you’d skip -d and run in the foreground or use -it for an interactive session.

The -d option runs the container in detached mode, meaning it starts in the background and is detached from your current terminal session. This lets the container keep running while you continue to use the shell, instead of tying up the terminal with the container’s foreground output. When you run in detached mode, you won’t see the container’s logs in real time in the terminal, but you can still view them later with commands like docker logs . In the given command, -d works with --rm so the container will run in the background and be automatically removed when it stops, while -P maps ports. If you need interactive work or live terminal output, you’d skip -d and run in the foreground or use -it for an interactive session.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy