0
0
Dockerdevops~10 mins

Development vs production Dockerfiles - Interactive Practice

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

Complete the Dockerfile line to set the base image for development.

Docker
FROM [1]
Drag options to blanks, or click blank then click option'
Anode:18-alpine
Bubuntu:latest
Cpython:3.12-slim
Dnginx:stable
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a base image unrelated to the app language.
2fill in blank
medium

Complete the command to copy source code into the container in the development Dockerfile.

Docker
COPY [1] /app
Drag options to blanks, or click blank then click option'
Asrc/
Bdist/
Cnode_modules/
Dconfig/
Attempts:
3 left
💡 Hint
Common Mistakes
Copying built files instead of source code.
3fill in blank
hard

Fix the error in the production Dockerfile line that installs dependencies.

Docker
RUN npm [1] --production
Drag options to blanks, or click blank then click option'
Arun
Bupdate
Cinstall
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using npm run or npm start instead of install.
4fill in blank
hard

Fill both blanks to set the working directory and expose the port in the production Dockerfile.

Docker
WORKDIR [1]
EXPOSE [2]
Drag options to blanks, or click blank then click option'
A/app
B3000
C8080
D/usr/src/app
Attempts:
3 left
💡 Hint
Common Mistakes
Using development paths or wrong ports.
5fill in blank
hard

Fill all three blanks to create a multi-stage production Dockerfile that builds and runs the app.

Docker
FROM node:18-alpine AS builder
WORKDIR [1]
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

FROM node:18-alpine
WORKDIR [2]
COPY --from=builder [1]/[3] ./
CMD ["node", "dist/index.js"]
Drag options to blanks, or click blank then click option'
A/app
B/usr/src/app
Cdist
Dsrc
Attempts:
3 left
💡 Hint
Common Mistakes
Using different working directories or copying wrong folders.