Which command is used to install nginx in a Dockerfile?

Prepare for the Cisco Certified DevNet Associate Exam. Use flashcards and multiple choice questions to boost your knowledge, with hints and explanations to guide you. Ace your exam effectively!

The command used to install nginx in a Dockerfile is "RUN apt-get install nginx -y." This command is executed during the build process of the Docker image. The "RUN" instruction in a Dockerfile allows you to execute commands in a new layer on top of the current image and commit the results. Specifically, the command "apt-get install nginx -y" tells the package manager to install the nginx web server and the "-y" flag automatically answers "yes" to any prompts, allowing the installation to proceed without user interaction.

The other options do not serve the purpose of installing nginx. The "MAINTAINER" instruction is used to specify the author of the Dockerfile, not for installing software. The "CMD" instruction specifies the default command to run when a container is started from the image, but it does not install any software. The "FROM" instruction is used to specify a base image for the Docker image being created but does not install nginx; it simply indicates that the image is based on nginx if that image exists in a registry. Thus, the correct choice effectively carries out the installation of nginx within the Dockerfile's context.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy