K8s Applications mit MicroK8S auf Raspberry PI. Alfred Sabitzer
Чтение книги онлайн.

Читать онлайн книгу K8s Applications mit MicroK8S auf Raspberry PI - Alfred Sabitzer страница 21

Название: K8s Applications mit MicroK8S auf Raspberry PI

Автор: Alfred Sabitzer

Издательство: Bookwire

Жанр: Математика

Серия:

isbn: 9783742770134

isbn:

СКАЧАТЬ syntax=docker/dockerfile:1

      # Alpine is chosen for its small footprint

      # compared to Ubuntu

      FROM golang:1.16-alpine

      WORKDIR /app

      # Download necessary Go modules

      COPY go.mod ./

      COPY go.sum ./

      RUN go mod download

      COPY *.go ./

      COPY hello.html ./

      COPY error.html ./

      RUN go build -o /GetInfo

      EXPOSE 8080

      CMD [ "/GetInfo" ]

      alfred@monitoring:~/GetInfo$

      um den Container zu bauen.

      alfred@monitoring:~/GetInfo$ docker build . -t docker.registry:5000/getinfo:20211015

      Sending build context to Docker daemon 16.38kB

      Step 1/11 : FROM golang:1.16-alpine

      1.16-alpine: Pulling from library/golang

      552d1f2373af: Pull complete

      eb74239f2a0c: Pull complete

      2a8ec004bf6b: Pull complete

      12f1fa1a3b20: Pull complete

      5c12166b7f9d: Pull complete

      Digest: sha256:05df7ff684a2cb06aa207be14a78918cbc3285ed3b965974979e575d59de1c11

      Status: Downloaded newer image for golang:1.16-alpine

       ---> d2f4346f5656

      Step 2/11 : WORKDIR /app

       ---> Running in 9b6c3b098321

      Removing intermediate container 9b6c3b098321

       ---> 738bd59f63db

      Step 3/11 : COPY go.mod ./

       ---> cb6306d5fdf2

      Step 4/11 : COPY go.sum ./

       ---> f7eeef9ebda2

      Step 5/11 : RUN go mod download

       ---> Running in efbe89b22883

      Removing intermediate container efbe89b22883

       ---> cb738e90d4d7

      Step 6/11 : COPY *.go ./

       ---> c5ab2f4e9e5c

      Step 7/11 : COPY hello.html ./

       ---> 8e6738e25799

      Step 8/11 : COPY error.html ./

       ---> 5c9506b2dc3f

      Step 9/11 : RUN go build -o /GetInfo.go

       ---> Running in 3ad675aeb626

      Removing intermediate container 3ad675aeb626

       ---> 0abfe5a9d849

      Step 10/11 : EXPOSE 8080

       ---> Running in 80f728420378

      Removing intermediate container 80f728420378

       ---> b9c5a76c55d2

      Step 11/11 : CMD [ "/GetInfo" ]

       ---> Running in 71d6f27934d2

      Removing intermediate container 71d6f27934d2

       ---> 4fae231152c2

      Successfully built 4fae231152c2

      Successfully tagged docker.registry:5000/getinfo:20211015

      alfred@monitoring:~/GetInfo$

      alfred@monitoring:~/GetInfo$ docker images

      REPOSITORY TAG IMAGE ID CREATED SIZE

      docker.registry:5000/getinfo 20211015 4fae231152c2 39 seconds ago 317MB

      golang 1.16-alpine d2f4346f5656 2 days ago 296MB

      alfred@monitoring:~/GetInfo$

      Nun starten wir den Container im Vordergrund um den Output zu testen.

      alfred@monitoring:~/GetInfo$ docker run --publish 8080:8080 docker.registry:5000/getinfo:20211015

      2021/10/15 19:22:13 Main Started

      2021/10/15 19:22:40 hello.html

      Der Output im Browser ist wie folgt:

      OEBPS/images/image0023.jpg Abbildung 21: Docker Test Output

      Der Container ist am erwarteten Port erreichbar. Die Anzeige der Werte sind jetzt aus Sicht des Containers, wie man an den Variablen und am Environment sehen kann.

      Wir überprüfen die Struktur des gebauten docker-files.

      alfred@monitoring:~/GetInfo$ docker save docker.registry:5000/getinfo:20211015 > getinfo.tar

      alfred@monitoring:~/GetInfo$ tar -tvf getinfo.tar

      -rw-r--r-- 0/0 7059 2021-10-15 21:22 0fca605bf404203fe0e1d41e306687bf70b8cdb4392c41363af0f6712ae28959.json

      drwxr-xr-x 0/0 0 2021-10-15 21:22 11ada22ca4865de4368da5b2cdea81c34f3fc62b60e62f00329f839e1e51a431/

      -rw-r--r-- 0/0 3 2021-10-15 21:22 11ada22ca4865de4368da5b2cdea81c34f3fc62b60e62f00329f839e1e51a431/VERSION

      -rw-r--r-- 0/0 406 2021-10-15 21:22 11ada22ca4865de4368da5b2cdea81c34f3fc62b60e62f00329f839e1e51a431/json

      -rw-r--r-- 0/0 5605376 2021-10-15 21:22 11ada22ca4865de4368da5b2cdea81c34f3fc62b60e62f00329f839e1e51a431/layer.tar

      drwxr-xr-x 0/0 0 2021-10-15 21:22 1a41da37655e1ae130db0ff268801f26989f408ad4e24fee81b18252883fe835/

      -rw-r--r-- 0/0 3 2021-10-15 21:22 1a41da37655e1ae130db0ff268801f26989f408ad4e24fee81b18252883fe835/VERSION

      -rw-r--r-- 0/0 482 2021-10-15 21:22 1a41da37655e1ae130db0ff268801f26989f408ad4e24fee81b18252883fe835/json

      -rw-r--r-- СКАЧАТЬ