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:
- Create a file
#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/hello /app/hello CMD /app/hello
- Some characteristics of a Docker image are:
- It is immutable
- It is composed of immutable layers
- Each layer contains only what has changed (the delta) in regard to the lower lying layers
- An image is a (big) tarball of files and folders
- an image is a template for containers
- Option 3 is correct. First we need to make sure we're logged in and then we tag the image and finally push it. Since it is an image we're using
docker image ...
and notdocker container ...
(as in number 4).