MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Docker Tutorials: Image – Creating a docker image using scratch

You can use Docker’s reserved, minimal image, scratch, as a starting point for building containers. Using the scratch “image” signals to the build process that you want the next command in the Dockerfile to be the first filesystem layer in your image.

There is a scratch image on docker hub, but it’s essentially just the canvas for creating base images, it’s essentially useless until you setup an OS and create a new image from it. you’ll likely never need to use it unless you’ve written your own operating system, as just about every existing platform is already present in some form or another as a base image for you to build upon.

The scratch image is the most minimal image in Docker. This is the base ancestor for all other images. The scratch image is actually empty. It doesn’t contain any folders/files …

The scratch image is mostly used for building other base images. For instance, the debian image is built from scratch as such:

FROM scratch  
ADD rootfs.tar.xz /  
CMD ["bash"]

The rootfs.tar.xz contains all the files system files. The Debian image adds the filesystem folders to the scratch image, which is empty.

While scratch appears in Docker’s repository on the hub, you can’t pull it, run it, or tag any image with the name scratch. Instead, you can refer to it in your Dockerfile. For example, to create a minimal container using scratch:

FROM scratchADD hello /CMD ["/hello"]

Assuming you built the “hello” executable example from the Docker GitHub example C-source code, and you compiled it with the -static flag, you can then build this Docker image using: docker build –tag hello .

The scratch image is blank.The hello-world executable added to the scratch image is actually statically compiled, meaning that it is self-contained and doesn’t need any additional libraries to execute.

$ docker run --rm -it -v $PWD:/build ubuntu:16.04
container# apt-get update && apt-get install build-essential
container# cd /build
container# gcc -o hello -static -nostartfiles hello.c

Then you can run it (on Linux, Mac, or Windows) using: docker run –rm hello

There are more example scripts for creating parent images in the Docker GitHub Repo:

There are one very good reference of understanding and creating the docker images from scratch are

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Docker Tutorials: Docker Image – Example and Sample Programs of Dockerfile

This page collects sample Dockerfiles that build an Ubuntu-based Apache image and show how CMD, ENTRYPOINT, EXPOSE, ARG, ENV, COPY and USER behave. Below the examples you…

Read More

Docker Training Agenda: A Hands-On Learning Path from Containers to Registries and Networking

This revised Docker training agenda turns the original outline into a practical, modern learning path for beginners and early-career DevOps engineers. It maps each module to hands-on outcomes, core commands, and common implementation decisions.

Read More

Docker Tutorials: Docker Image – Understanding Dockerfiles instructions & options

Here’s a step-by-step tutorial for Dockerfile, including explanations and examples for each major command. Dockerfile Tutorial A Dockerfile is a text file containing instructions to build a…

Read More

Docker Lab & Assignment – Creating an Image

Here’s a detailed Tutorial and Lab Guide for the listed Docker commands, focused on practical usage, explanations, and step-by-step labs with Ubuntu + git + apache2 as…

Read More

GitLab Deploy – Container Registry – A Complete Guide

Here’s a complete step-by-step guide for: ✅ Building a Docker image✅ Storing (pushing) it to GitLab’s Container Registry✅ Using GitLab CI/CD pipeline with GitLab SaaS 18.x 🚀…

Read More

Docker commands Guide – docker build with examples

Here’s a complete tutorial on docker build, explaining what it does, examples, and use cases. What is docker build? docker build is a Docker command used to…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x