HelloWorld Cheatsheet for
- installing Docker
- creating a small small c-program
- creating a Docker Image containing and executing that c file with Dockerfile
# 2 options:
# this provided by the Linux distribution
sudo apt install docker.io
# this is provided by docker.inc
sudo apt-get install docker-ce docker-ce-cli containerd.io
#
sudo apt install build-essential
#include <stdio.h>
int main() {
printf("Hello World!\n");
return 0;
}gcc -o hello --static hello.c
- create a file called "Dockerfile" with following content:
# indicates that this image will start from an empty image
FROM scratch
# copies a file hello to the root filesystem
COPY hello /
# executes the hello program
CMD ["/hello"]sudo docker image build -t helloimage .
sudo docker images
sudo docker ps
docker run helloimage