0
0
Dockerdevops~10 mins

Named build stages in Docker - Interactive Code Practice

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

Complete the Dockerfile to name the first build stage as 'builder'.

Docker
FROM node:18 AS [1]
WORKDIR /app
COPY package.json ./
RUN npm install
Drag options to blanks, or click blank then click option'
Abuilder
Bstage1
Cbuild
Dbase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'build' or 'base' instead of 'builder' which is the conventional name.
Omitting the AS keyword and stage name.
2fill in blank
medium

Complete the Dockerfile to copy files from the named build stage 'builder'.

Docker
FROM nginx:alpine
COPY --from=[1] /app/build /usr/share/nginx/html
Drag options to blanks, or click blank then click option'
Abuild
Bbase
Cstage1
Dbuilder
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'build' or 'base' which are not the correct stage names.
Forgetting to use the --from option.
3fill in blank
hard

Fix the error in the Dockerfile by correctly naming the build stage.

Docker
FROM python:3.12 AS [1]
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt
Drag options to blanks, or click blank then click option'
Astage
Bbuild-stage
Cbuilder
Dpython-builder
Attempts:
3 left
💡 Hint
Common Mistakes
Using names with hyphens which can cause issues in some contexts.
Using generic names like 'stage' that are not descriptive.
4fill in blank
hard

Fill both blanks to create a multi-stage Dockerfile that builds and then copies from the 'builder' stage.

Docker
FROM golang:1.20 AS [1]
WORKDIR /src
COPY . .
RUN go build -o app

FROM alpine:latest
COPY --from=[2] /src/app /usr/local/bin/app
Drag options to blanks, or click blank then click option'
Abuilder
Bbuild
Cstage1
Dbase
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names in the AS and --from parts.
Using generic names like 'build' or 'stage1' inconsistently.
5fill in blank
hard

Fill all three blanks to create a multi-stage Dockerfile with named stages and copy commands.

Docker
FROM rust:1.70 AS [1]
WORKDIR /app
COPY . .
RUN cargo build --release

FROM debian:buster-slim AS [2]
COPY --from=[3] /app/target/release/myapp /usr/local/bin/myapp
Drag options to blanks, or click blank then click option'
Abuilder
Bfinal
Cbuild
Dstage
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up stage names between AS and --from.
Using inconsistent or generic names that don't match.