CompTIA Linux+ (XK0-005) — Question 270

A Linux administrator needs to expose port 9000 for a container to listen during runtime. The Linux administrator creates a Dockerfile with the following entries.

# Test-Container

FROM node:9-alpine -

WORDDIR /usr/src/app -
COPY package*.json ./

RUN npm install -
copy . .

EXPOSE 9000 -
CMD ['npm", "start"]

Which of the following commands should the administrator use to accomplish this task? (Choose two).

Answer options

Correct answer: A, D

Explanation

The correct command A, 'docker build -t Test-Container', is used to build the Docker image with the specified tag. Command D, 'docker run -p 9000:80 Test-Container', maps port 9000 on the host to port 80 on the container, allowing the application to be accessed. The other commands do not fulfill the requirement of exposing the port or building the container.