Challenge - 5 Problems
Scratch Image Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of a Scratch-based Dockerfile with a simple file copy
Consider this Dockerfile using the scratch base image:
What will happen when you run this container?
FROM scratch COPY hello.txt /hello.txt CMD ["/hello.txt"]
What will happen when you run this container?
Docker
FROM scratch
COPY hello.txt /hello.txt
CMD ["/hello.txt"]Attempts:
2 left
💡 Hint
Scratch images have no shell or runtime environment.
✗ Incorrect
The scratch image is empty and has no shell or runtime. Copying a text file and trying to run it as a command will fail because the file is not executable.
🧠 Conceptual
intermediate1:30remaining
Why use the scratch base image in Docker?
Which of the following is the main reason to use the scratch base image in Docker containers?
Attempts:
2 left
💡 Hint
Think about container size and minimalism.
✗ Incorrect
The scratch image is empty and used to build minimal containers containing only the application and its required files, reducing size and attack surface.
❓ Troubleshoot
advanced2:30remaining
Troubleshooting a failing scratch container with a Go binary
You built a Go application statically linked and created this Dockerfile:
The container fails to start with 'exec format error'. What is the most likely cause?
FROM scratch COPY app /app CMD ["/app"]
The container fails to start with 'exec format error'. What is the most likely cause?
Docker
FROM scratch
COPY app /app
CMD ["/app"]Attempts:
2 left
💡 Hint
Exec format errors usually relate to binary compatibility.
✗ Incorrect
An exec format error means the binary is not compatible with the CPU architecture of the host. Scratch image runs the binary directly, so architecture must match.
🔀 Workflow
advanced2:00remaining
Correct workflow to build a minimal scratch container for a static binary
Which sequence of commands correctly builds and runs a minimal scratch container for a statically compiled binary named 'myapp'?
Attempts:
2 left
💡 Hint
Think about building an image and then running it.
✗ Incorrect
You build the image with docker build and then run it with docker run. Scratch images have no shell, so running /bin/sh or exec inside won't work.
✅ Best Practice
expert3:00remaining
Best practice for adding dependencies to a scratch-based container
You want to create a scratch-based container that runs a Python script. Which approach is best to include Python and your script in the container?
Attempts:
2 left
💡 Hint
Scratch images are empty and cannot install packages by themselves.
✗ Incorrect
Scratch images are empty. To run Python, you must copy the Python interpreter and libraries from a full image using multi-stage builds.