#include <stdio.h> #include <stdlib.h> int is_prime(int number) { for (int possible_factor = 2; possible_factor < number; possible_factor++) { if (number % possible_factor == 0) { return 0; } } return 1; } int main(int argc, char *argv[]) { int n = atoi(argv[1]); int n_primes = 0; for (int number = 2; n_primes < n; number++) { n_primes += is_prime(number); if (n_primes == n) { printf("%d\n", number); return 0; } } }
import os, shutil, sys myname = os.path.basename(sys.argv[0]) if myname == "echo": print(*sys.argv[1:]) elif myname == "cp": shutil.copyfile(sys.argv[1], sys.argv[2]) elif myname == "rm": for pathname in sys.argv[1:]: os.unlink(pathname) else: print(f"Unknown name: {myname}", file=sys.stderr)
#include <stdio.h> #include <linux/reboot.h> #include <sys/reboot.h> int main(void) { printf("hello from myinit\n"); reboot(LINUX_REBOOT_CMD_POWER_OFF); }
FROM alpine RUN \ apk update &&\ # install apache web server apk add apache2 curl &&\ # a configuration file Apache needs echo ServerName my-web-server >/etc/apache2/conf.d/localhost.conf # add a file to the image for our webserver to serve ADD hello.txt /var/www/localhost/htdocs/hello.txt # run web-server plus shell when container started ENTRYPOINT \ /usr/sbin/httpd &&\ ash &&\ killall httpd