0
0
Node.jsframework~10 mins

Docker containerization for Node.js in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the Dockerfile to specify the base image for a Node.js app.

Node.js
FROM [1]
Drag options to blanks, or click blank then click option'
Anode:18-alpine
Bpython:3.9
Cubuntu:latest
Dnginx:stable
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-Node.js base image like Python or Nginx.
Forgetting to specify a version tag.
2fill in blank
medium

Complete the Dockerfile to copy the package.json file into the container.

Node.js
COPY [1] ./
Drag options to blanks, or click blank then click option'
Apackage.json
Bsrc/package.json
Capp.js
Dnode_modules
Attempts:
3 left
💡 Hint
Common Mistakes
Copying the wrong file like app.js or node_modules.
Using a wrong path like src/package.json when the file is in the root.
3fill in blank
hard

Fix the error in the Dockerfile command to install dependencies.

Node.js
RUN npm [1]
Drag options to blanks, or click blank then click option'
Astart
Btest
Cinstall
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using npm start which runs the app instead of installing.
Using npm build which is not a standard npm command.
4fill in blank
hard

Fill both blanks to set the working directory and copy all app files.

Node.js
WORKDIR [1]
COPY [2] ./
Drag options to blanks, or click blank then click option'
A/usr/src/app
Bsrc/
C.
D/app
Attempts:
3 left
💡 Hint
Common Mistakes
Using relative paths incorrectly for WORKDIR.
Copying from a wrong source directory like src/ when files are in root.
5fill in blank
hard

Fill all three blanks to expose port 3000, set environment variable NODE_ENV to production, and define the command to start the app.

Node.js
EXPOSE [1]
ENV NODE_ENV=[2]
CMD ["npm", "[3]"]
Drag options to blanks, or click blank then click option'
Adevelopment
Bproduction
Cstart
D3000
Attempts:
3 left
💡 Hint
Common Mistakes
Exposing the wrong port number.
Setting NODE_ENV to development instead of production.
Using npm run or other commands instead of npm start.