Docker standard_init_linux.go:228: exec user process caused: no such file or directory

Issue

Whenever I am trying to run the docker images, it is exiting in immediately.

CONTAINER ID   IMAGE                      COMMAND                CREATED          STATUS                      PORTS     NAMES
ae327a2bdba3   k8s-for-beginners:v0.0.1   "/k8s-for-beginners"   11 seconds ago   Exited (1) 10 seconds ago             focused_booth

As per Container Logs

standard_init_linux.go:228: exec user process caused: no such file or directory

I have created all the files in linux itself:

FROM alpine:3.10
COPY k8s-for-beginners /
CMD ["/k8s-for-beginners"]

GO Code:

package main

import (
    "fmt"
    "log"
    "net/http"
)

func main() {
    http.HandleFunc("/", handler)
    log.Fatal(http.ListenAndServe("0.0.0.0:8080", nil))
}

func handler(w http.ResponseWriter, r *http.Request) {
    log.Printf("Ping from %s", r.RemoteAddr)
    fmt.Fprintln(w, "Hello Kubernetes Beginners!")
}

This is the first exercise from THE KUBERNETES WORKSHOP book.

Commands I have used in this Process:

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o k8s-for-beginners
sudo docker build -t k8s-for-beginners:v0.0.1 .
sudo docker run -p 8080:8080 -d k8s-for-beginners:v0.0.1

Output of sudo docker run k8s-for-beginners:v0.0.1 ldd /k8s-for-beginners

        /lib64/ld-linux-x86-64.so.2 (0x7f9ab5778000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f9ab5778000)
Error loading shared library libgo.so.16: No such file or directory (needed by /k8s-for-beginners)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /k8s-for-beginners)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /k8s-for-beginners)
Error relocating /k8s-for-beginners: crypto..z2frsa..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fx509..import: symbol not found
Error relocating /k8s-for-beginners: log..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fmd5..import: symbol not found
Error relocating /k8s-for-beginners: crypto..import: symbol not found
Error relocating /k8s-for-beginners: bytes..import: symbol not found
Error relocating /k8s-for-beginners: fmt.Fprintln: symbol not found
Error relocating /k8s-for-beginners: crypto..z2felliptic..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fx509..z2fpkix..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2frand..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fchacha20poly1305..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fcurve25519..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fidna..import: symbol not found
Error relocating /k8s-for-beginners: internal..z2foserror..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fecdsa..import: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp.HandleFunc: symbol not found
Error relocating /k8s-for-beginners: io..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fhttp2..z2fhpack..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fcipher..import: symbol not found
Error relocating /k8s-for-beginners: log.Fatal: symbol not found
Error relocating /k8s-for-beginners: math..z2fbig..import: symbol not found
Error relocating /k8s-for-beginners: runtime..import: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp..import: symbol not found
Error relocating /k8s-for-beginners: hash..z2fcrc32..import: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp.ListenAndServe: symbol not found
Error relocating /k8s-for-beginners: context..import: symbol not found
Error relocating /k8s-for-beginners: fmt..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2ftls..import: symbol not found
Error relocating /k8s-for-beginners: errors..import: symbol not found
Error relocating /k8s-for-beginners: internal..z2ftestlog..import: symbol not found
Error relocating /k8s-for-beginners: runtime.setIsCgo: symbol not found
Error relocating /k8s-for-beginners: runtime_m: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fhex..import: symbol not found
Error relocating /k8s-for-beginners: mime..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2funicode..z2fbidi..import: symbol not found
Error relocating /k8s-for-beginners: internal..z2freflectlite..import: symbol not found
Error relocating /k8s-for-beginners: compress..z2fgzip..import: symbol not found
Error relocating /k8s-for-beginners: sync..import: symbol not found
Error relocating /k8s-for-beginners: compress..z2fflate..import: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fbinary..import: symbol not found
Error relocating /k8s-for-beginners: math..z2frand..import: symbol not found
Error relocating /k8s-for-beginners: runtime_cpuinit: symbol not found
Error relocating /k8s-for-beginners: internal..z2fpoll..import: symbol not found
Error relocating /k8s-for-beginners: mime..z2fmultipart..import: symbol not found
Error relocating /k8s-for-beginners: runtime.check: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fcryptobyte..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsha512..import: symbol not found
Error relocating /k8s-for-beginners: runtime.registerTypeDescriptors: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fchacha20..import: symbol not found
Error relocating /k8s-for-beginners: runtime.setmodinfo: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2ftransform..import: symbol not found
Error relocating /k8s-for-beginners: time..import: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fbase64..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsha256..import: symbol not found
Error relocating /k8s-for-beginners: __go_go: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fhttp..z2fhttpguts..import: symbol not found
Error relocating /k8s-for-beginners: path..z2ffilepath..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2fsecure..z2fbidirule..import: symbol not found
Error relocating /k8s-for-beginners: os..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fhttp..z2fhttpproxy..import: symbol not found
Error relocating /k8s-for-beginners: net..z2ftextproto..import: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fasn1..import: symbol not found
Error relocating /k8s-for-beginners: runtime.requireitab: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fdns..z2fdnsmessage..import: symbol not found
Error relocating /k8s-for-beginners: path..import: symbol not found
Error relocating /k8s-for-beginners: io..z2fioutil..import: symbol not found
Error relocating /k8s-for-beginners: sort..import: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2funicode..z2fnorm..import: symbol not found
Error relocating /k8s-for-beginners: internal..z2fcpu..import: symbol not found
Error relocating /k8s-for-beginners: runtime.ginit: symbol not found
Error relocating /k8s-for-beginners: runtime.osinit: symbol not found
Error relocating /k8s-for-beginners: runtime.schedinit: symbol not found
Error relocating /k8s-for-beginners: bufio..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2finternal..z2frandutil..import: symbol not found
Error relocating /k8s-for-beginners: runtime_mstart: symbol not found
Error relocating /k8s-for-beginners: net..import: symbol not found
Error relocating /k8s-for-beginners: strconv..import: symbol not found
Error relocating /k8s-for-beginners: runtime.args: symbol not found
Error relocating /k8s-for-beginners: runtime..z2finternal..z2fsys..import: symbol not found
Error relocating /k8s-for-beginners: runtime.newobject: symbol not found
Error relocating /k8s-for-beginners: syscall..import: symbol not found
Error relocating /k8s-for-beginners: unicode..import: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp..z2finternal..import: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fpem..import: symbol not found
Error relocating /k8s-for-beginners: _Unwind_Resume: symbol not found
Error relocating /k8s-for-beginners: reflect..import: symbol not found
Error relocating /k8s-for-beginners: mime..z2fquotedprintable..import: symbol not found
Error relocating /k8s-for-beginners: log.Printf: symbol not found
Error relocating /k8s-for-beginners: runtime.typedmemmove: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fdsa..import: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsha1..import: symbol not found
Error relocating /k8s-for-beginners: bufio..types: symbol not found
Error relocating /k8s-for-beginners: bytes..types: symbol not found
Error relocating /k8s-for-beginners: compress..z2fflate..types: symbol not found
Error relocating /k8s-for-beginners: compress..z2fgzip..types: symbol not found
Error relocating /k8s-for-beginners: context..types: symbol not found
Error relocating /k8s-for-beginners: crypto..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fcipher..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fdsa..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fecdsa..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2felliptic..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2finternal..z2frandutil..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fmd5..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2frand..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2frsa..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsha1..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsha256..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsha512..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2ftls..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fx509..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fx509..z2fpkix..types: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fasn1..types: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fbase64..types: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fbinary..types: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fhex..types: symbol not found
Error relocating /k8s-for-beginners: encoding..z2fpem..types: symbol not found
Error relocating /k8s-for-beginners: errors..types: symbol not found
Error relocating /k8s-for-beginners: fmt..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fchacha20..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fchacha20poly1305..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fcryptobyte..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fcurve25519..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fdns..z2fdnsmessage..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fhttp..z2fhttpguts..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fhttp..z2fhttpproxy..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fhttp2..z2fhpack..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fnet..z2fidna..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2fsecure..z2fbidirule..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2ftransform..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2funicode..z2fbidi..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2ftext..z2funicode..z2fnorm..types: symbol not found
Error relocating /k8s-for-beginners: hash..z2fcrc32..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fcpu..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2foserror..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fpoll..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2freflectlite..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2ftestlog..types: symbol not found
Error relocating /k8s-for-beginners: io..types: symbol not found
Error relocating /k8s-for-beginners: io..z2fioutil..types: symbol not found
Error relocating /k8s-for-beginners: log..types: symbol not found
Error relocating /k8s-for-beginners: math..z2fbig..types: symbol not found
Error relocating /k8s-for-beginners: math..z2frand..types: symbol not found
Error relocating /k8s-for-beginners: mime..types: symbol not found
Error relocating /k8s-for-beginners: mime..z2fmultipart..types: symbol not found
Error relocating /k8s-for-beginners: mime..z2fquotedprintable..types: symbol not found
Error relocating /k8s-for-beginners: net..types: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp..types: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp..z2finternal..types: symbol not found
Error relocating /k8s-for-beginners: net..z2ftextproto..types: symbol not found
Error relocating /k8s-for-beginners: os..types: symbol not found
Error relocating /k8s-for-beginners: path..types: symbol not found
Error relocating /k8s-for-beginners: path..z2ffilepath..types: symbol not found
Error relocating /k8s-for-beginners: reflect..types: symbol not found
Error relocating /k8s-for-beginners: runtime..types: symbol not found
Error relocating /k8s-for-beginners: runtime..z2finternal..z2fsys..types: symbol not found
Error relocating /k8s-for-beginners: sort..types: symbol not found
Error relocating /k8s-for-beginners: strconv..types: symbol not found
Error relocating /k8s-for-beginners: sync..types: symbol not found
Error relocating /k8s-for-beginners: syscall..types: symbol not found
Error relocating /k8s-for-beginners: time..types: symbol not found
Error relocating /k8s-for-beginners: unicode..types: symbol not found
Error relocating /k8s-for-beginners: container..z2flist..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2faes..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fdes..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fed25519..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fed25519..z2finternal..z2fedwards25519..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fhmac..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2finternal..z2fsubtle..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2frc4..types: symbol not found
Error relocating /k8s-for-beginners: crypto..z2fsubtle..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fcryptobyte..z2fasn1..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fhkdf..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2finternal..z2fsubtle..types: symbol not found
Error relocating /k8s-for-beginners: golang.x2eorg..z2fx..z2fcrypto..z2fpoly1305..types: symbol not found
Error relocating /k8s-for-beginners: hash..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fbytealg..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2ffmtsort..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fnettrace..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2frace..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fsingleflight..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fsyscall..z2fexecenv..types: symbol not found
Error relocating /k8s-for-beginners: internal..z2fsyscall..z2funix..types: symbol not found
Error relocating /k8s-for-beginners: math..types: symbol not found
Error relocating /k8s-for-beginners: math..z2fbits..types: symbol not found
Error relocating /k8s-for-beginners: net..z2fhttp..z2fhttptrace..types: symbol not found
Error relocating /k8s-for-beginners: net..z2furl..types: symbol not found
Error relocating /k8s-for-beginners: runtime..z2finternal..z2fatomic..types: symbol not found
Error relocating /k8s-for-beginners: runtime..z2finternal..z2fmath..types: symbol not found
Error relocating /k8s-for-beginners: strings..types: symbol not found
Error relocating /k8s-for-beginners: sync..z2fatomic..types: symbol not found
Error relocating /k8s-for-beginners: unicode..z2futf16..types: symbol not found
Error relocating /k8s-for-beginners: unicode..z2futf8..types: symbol not found
Error relocating /k8s-for-beginners: runtime.strequal..f: symbol not found
Error relocating /k8s-for-beginners: runtime.memequal64..f: symbol not found
Error relocating /k8s-for-beginners: type...1reflect.rtype: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Align: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Align: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.AssignableTo: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.AssignableTo: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Bits: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Bits: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.ChanDir: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.ChanDir: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Comparable: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Comparable: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.ConvertibleTo: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.ConvertibleTo: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Elem: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Elem: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Field: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Field: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldAlign: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldAlign: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldByIndex: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldByIndex: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldByName: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldByName: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldByNameFunc: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.FieldByNameFunc: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Implements: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Implements: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.In: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.In: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.IsVariadic: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.IsVariadic: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Key: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Key: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Kind: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Kind: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Len: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Len: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Method: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Method: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.MethodByName: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.MethodByName: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Name: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Name: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumField: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumField: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumIn: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumIn: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumMethod: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumMethod: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumOut: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.NumOut: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Out: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Out: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.PkgPath: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.PkgPath: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Size: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.Size: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.String: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.String: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.common: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.common: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.rawString: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.rawString: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.uncommon..stub: symbol not found
Error relocating /k8s-for-beginners: reflect.rtype.uncommon..stub: symbol not found
Error relocating /k8s-for-beginners: reflect..reflect.rtype..d: symbol not found
Error relocating /k8s-for-beginners: type...1net.IPAddr: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.Network: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.Network: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.String: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.String: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.family: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.family: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.isWildcard: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.isWildcard: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.sockaddr: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.sockaddr: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.toLocal: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr.toLocal: symbol not found
Error relocating /k8s-for-beginners: net.IPAddr..d: symbol not found
Error relocating /k8s-for-beginners: runtime.main: symbol not found
Error relocating /k8s-for-beginners: runtime_iscgo: symbol not found
Error relocating /k8s-for-beginners: runtime_isstarted: symbol not found
Error relocating /k8s-for-beginners: runtime_isarchive: symbol not found
Error relocating /k8s-for-beginners: __gcc_personality_v0: symbol not found
Error relocating /k8s-for-beginners: io.Writer..d: symbol not found
Error relocating /k8s-for-beginners: runtime.writeBarrier: symbol not found

Solution

Since you’re already using Docker, I’d suggest using a multi-stage build. Using a standard docker image like golang one can build an executable asset which is guaranteed to work with other docker linux images:

FROM golang:1.17 as builder

# first (build) stage

WORKDIR /app
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 go build -o k8s-for-beginners

# final (target) stage

FROM alpine:3.10
COPY --from=builder /app/k8s-for-beginners /
CMD ["/k8s-for-beginners"]

Note: you since you are using CGO_ENABLED=0 you can run your app in a much smaller scratch container. To do so replace FROM alpine:3.10 with FROM scratch


P.S. ensure you have a go.mod file in the same directory as the Go source and Dockerfile:

go mod init k8sapp     # creates a `go.mod`

or you can create go.mod manually:

module k8sapp

go 1.17

Answered By – colm.anseo

Answer Checked By – Clifford M. (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.