Here's an unusual, but simple, example of a function. In this example, we'll try to compile, pack, and deploy a C program as a function. Why a C program? Basically, if we know that we can pack a C program, then any traditional program could be compiled and packed in a similar way.
We know that when we design a function, it receives an input from stdin and sends an output to stdout. A C program will then send a simple sentence out to stdout, of course with printf():
#include <stdio.h>int main() { printf("%s\n", "hello function"); return 0;}
Normally, this C program can be compiled using gcc before copying and packing it as a container. But to make a Dockerfile self-contained, the multi-stage build technique will be used ...