K8s Applications mit MicroK8S auf Raspberry PI. Alfred Sabitzer

K8s Applications mit MicroK8S auf Raspberry PI - Alfred Sabitzer


Скачать книгу

      CMD ["/hallo"]

      alfred@monitoring:~/dev/hello-world$

      Nun bauen wir den Container.

      alfred@monitoring:~/dev/hello-world$ docker build . -t docker.registry:5000/hello-world:20211003

      Sending build context to Docker daemon 9.216kB

      Step 1/8 : FROM golang:1.16-alpine

      1.16-alpine: Pulling from library/golang

      be307f383ecc: Already exists

      e31131f141ae: Pull complete

      7f3ae2225eeb: Pull complete

      27b4cf6759f9: Pull complete

      05c56ed0aaf5: Pull complete

      Digest: sha256:45412fe3f5016509fc448b83faefc34e6f9e9bcc8ca1db1c54505d5528264e16

      Status: Downloaded newer image for golang:1.16-alpine

       ---> bebfc96a903d

      Step 2/8 : WORKDIR /app

       ---> Running in c81df142320d

      Removing intermediate container c81df142320d

       ---> a81936939cb7

      Step 3/8 : LABEL maintainer="[email protected]"

       ---> Running in 88c7acfdf90e

      Removing intermediate container 88c7acfdf90e

       ---> b023746a02d8

      Step 4/8 : COPY go.mod ./

       ---> 599501f1547a

      Step 5/8 : COPY *.go ./

       ---> 9f60a66c2ac0

      Step 6/8 : RUN go build -o /hallo

       ---> Running in 03fd6b04a839

      Removing intermediate container 03fd6b04a839

       ---> e62606c61d94

      Step 7/8 : EXPOSE 80

       ---> Running in 2b3562abb146

      Removing intermediate container 2b3562abb146

       ---> 121727752180

      Step 8/8 : CMD ["hallo"]

       ---> Running in cfa9e78598dc

      Removing intermediate container cfa9e78598dc

       ---> 52dfdc427a61

      Successfully built 52dfdc427a61

      Successfully tagged docker.registry:5000/hello-world:20211003

      alfred@monitoring:~/dev/hello-world$

      Anzeige im lokalen Repository.

      alfred@monitoring:~/go$ docker images

      REPOSITORY TAG IMAGE ID CREATED SIZE

      docker.registry:5000/hello-world 20211003 ebe5a2422dca 24 seconds ago 2.1MB

      alfred@monitoring:~/go$

      Wir können den Inhalt untersuchen, indem wir den Docker in ein Tar-File exportieren.

      alfred@monitoring:~/go$ docker ps -lq

      fc63f4826cff

      alfred@monitoring:~/go$

      alfred@monitoring:~/go$ mkdir test

      alfred@monitoring:~/go$ docker export fc63f4826cff > ./test/hello-world.tar

      alfred@monitoring:~/go$ cd test/

      alfred@monitoring:~/go/test$ tar -xf hello-world.tar

      alfred@monitoring:~/go/test$ ll

      total 4132

      drwxrwxr-x 6 alfred alfred 4096 Oct 3 09:37 ./

      drwxrwxr-x 4 alfred alfred 4096 Oct 3 09:37 ../

      -rwxr-xr-x 1 alfred alfred 0 Oct 3 09:32 .dockerenv*

      drwxr-xr-x 4 alfred alfred 4096 Oct 3 09:32 dev/

      drwxr-xr-x 2 alfred alfred 4096 Oct 3 09:32 etc/

      -rwxrwxr-x 1 alfred alfred 2097605 Sep 30 11:26 hello-world*

      -rw-rw-r-- 1 alfred alfred 2105344 Oct 3 09:37 hello-world.tar

      drwxr-xr-x 2 alfred alfred 4096 Oct 3 09:32 proc/

      drwxr-xr-x 2 alfred alfred 4096 Oct 3 09:32 sys/

      alfred@monitoring:~/go/test$

      Wir können das Image auch lokal starten.

      alfred@monitoring:~/dev/hello-world$ docker run docker.registry:5000/hello-world:20211003

      hello world

      alfred@monitoring:~/dev/hello-world$

      Pushen in das remote-Repository. In dem Falle gibt es einen darunter liegenden den Layer schon.

      alfred@monitoring:~/dev/hello-world$ docker push docker.registry:5000/hello-world:20211003

      The push refers to repository [docker.registry:5000/hello-world]

      6fa65fc3457a: Pushed

      af86841dfdf3: Pushed

      001055a1bdf7: Pushed

      350991c52258: Pushed

      93bd567aa306: Pushed

      b48145e02449: Pushed

      20211003: digest: sha256:cf16e57415939719367e5e17c09d2f17e36af2c1b84f24208f5750ea2c18b485 size: 1570

      alfred@monitoring:~/dev/hello-world$

      Anzeige aller vorhandenen Images im Remote Repository

      alfred@monitoring:~/go$ curl docker.registry:5000/v2/_catalog

      {"repositories":["hello-world"]}

      alfred@monitoring:~/go$

      alfred@monitoring:~/go$ curl docker.registry:5000/v2/hello-world/tags/list

      {"name":"hello-world","tags":["20211003","20211001","20210830","20210930"]}

      alfred@monitoring:~/go$

      alfred@monitoring:~/go$ curl docker.registry:5000/v2/hello-world/manifests/20211003

      {

       "schemaVersion": 1,

       "name": "hello-world",

       "tag": "20211003",

       "architecture": "arm64",

       "fsLayers": [

       {

       "blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"

       },

       {

       "blobSum": "sha256:34b32ef7cc99133a34d56a284820986ce50c2ff9c1864da8557458489d7428a1"

       }

       ],

       "history": [

       {

       "v1Compatibility": "{\"architecture\":\"arm64\",\"config\":{\"Hostname\":\"\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":[\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"],\"Cmd\":[\"/hello-world\"],\"Image\":\"sha256:c7642e609037b051e03214a85ddc50434de042a6b08c23bcac16dcb92629ee46\",\"Volumes\":null,\"WorkingDir\":\"\",\"Entrypoint\":null,\"OnBuild\":null,\"Labels\":null},\"container\":\"6d8917fc20a0fcbece354d49781ee260e15cb02df65c35efa5978f583948f9c4\",\"container_config\":{\"Hostname\":\"6d8917fc20a0\",\"Domainname\":\"\",\"User\":\"\",\"AttachStdin\":false,\"AttachStdout\":false,\"AttachStderr\":false,\"Tty\":false,\"OpenStdin\":false,\"StdinOnce\":false,\"Env\":[\"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"],\"Cmd\":[\"/bin/sh\",\"-c\",\"#(nop)


Скачать книгу