0
0
Dockerdevops~5 mins

Scratch base image for minimal containers in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the scratch base image in Docker?
The scratch base image is an empty image with no files or operating system. It is used to build minimal containers containing only your application and its dependencies.
Click to reveal answer
beginner
Why use the scratch image for containers?
Using scratch creates very small containers, improving security and performance by including only what is necessary to run the app.
Click to reveal answer
beginner
How do you specify the scratch image in a Dockerfile?
You write FROM scratch at the top of your Dockerfile to start building from an empty base image.
Click to reveal answer
intermediate
What must you include in a container built from scratch to make it runnable?
You must add your application binary and any required files manually because scratch has no OS or tools.
Click to reveal answer
beginner
Give an example of a simple Dockerfile using scratch.
Example:
FROM scratch
COPY myapp /
CMD ["/myapp"]
This copies a binary myapp into the container and runs it.
Click to reveal answer
What does the scratch image contain?
AA minimal Linux OS
BA full Ubuntu system
CNothing, it is empty
DOnly shell utilities
Which Dockerfile line starts a build from the scratch image?
AFROM scratch
BFROM ubuntu
CFROM alpine
DFROM base
Why might you choose scratch over other base images?
ATo create the smallest possible container
BTo get a full OS environment
CTo have pre-installed tools
DTo use a graphical interface
What must you do when using scratch as base image?
ANothing, it has everything needed
BInstall an OS inside the container
CUse a package manager
DManually add your app and dependencies
Which command runs your app in a scratch-based container?
ARUN /myapp
BCMD ["/myapp"]
CENTRYPOINT /bin/bash
DSTART /myapp
Explain what the scratch base image is and why it is useful.
Think about what is inside the image and what you need to add.
You got /4 concepts.
    Describe how to create a Dockerfile using the scratch image to run a simple binary.
    Focus on the minimal steps needed in the Dockerfile.
    You got /3 concepts.