Junior — Middle
Explain what it means to create a Docker image from scratch using the FROM instruction in a Dockerfile
sobes.tech AI
Answer from AI
The FROM instruction in a Dockerfile specifies the base image from which a new Docker image will be built. Creating an image "from scratch" (FROM scratch) means starting with an entirely empty image without any pre-installed layers or programs.
This is useful when you need to create a very lightweight and minimalistic image, for example, for statically compiled binaries where an operating system or additional dependencies are not required.
Example Dockerfile with FROM scratch:
FROM scratch
COPY myapp /myapp
CMD ["/myapp"]
Here, the image contains only your executable myapp without any additional layers.