Here are possible answers to the questions:
- Dockerfile:
FROM ubuntu:17.04
RUN apt-get update
RUN apt-get install -y ping
ENTRYPOINT ping
CMD 127.0.0.1
- To achieve the result you can execute the following steps:
$ docker container run -it --name sample \
alpine:latest /bin/sh
/ # apk update && \
apk add -y curl && \
rm -rf /var/cache/apk/*
/ # exit
$ docker container commit sample my-alpine:1.0
$ docker container rm sample
- As a sample here is the Hello World in C:
- Create a file hello.c with this content:
#include <stdio.h>
int main()
{
printf("Hello, World!");
return 0;
}
-
- Create a Dockerfile with this content:
FROM alpine:3.5 AS build
RUN apk update && \
apk add --update alpine-sdk
RUN mkdir /app
WORKDIR /app
COPY hello.c /app
RUN mkdir bin
RUN gcc -Wall hello.c -o bin/hello
FROM alpine:3.5
COPY --from=build /app/bin...