O'Reilly logo

Docker for Serverless Applications by Chanwit Kaewkasi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Packing a C program

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required