<p>This is my Dockerfile:</p>
<pre><code>FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY ls .
COPY tail .
COPY test .
COPY manager .
ENTRYPOINT [&quot;/manager&quot;]
</code></pre>
<p>after</p>
<pre><code>[root@master go-docker-test]# docker build -t strangething:v1.13 .
[root@master go-docker-test]# docker run -d strangething:v1.13
[root@master go-docker-test]# docker logs b2
</code></pre>
<p>it shows:</p>
<pre><code>exec /manager: no such file or directory
</code></pre>
<p>I'm pretty sure it is there. I use dive to see it:</p>
<pre><code>[Layers]───────────────────────────────────────────────────────────────────── [● Current Layer Contents]──────────────────────────────────────────────────
Cmp Image ID                     Size  Command                                Permission    UID:GID       Size  Filetree
    sha256:cb60fb9b862c6a89f9  2.3 MB  FROM sha256:cb60fb9b862c6a89f9         drwxr-xr-x        0:0     2.3 MB  ├── .
    sha256:3e884d7c2d4ba9bac6  118 kB  COPY ls . # buildkit                   drwxr-xr-x        0:0        0 B  │   ├── bin
    sha256:e75e9da8f1605f7944   67 kB  COPY tail . # buildkit                 drwxr-xr-x        0:0        0 B  │   ├── boot
    sha256:7a0f1970f36a364672  1.8 MB  COPY test . # buildkit                 drwxr-xr-x        0:0        0 B  │   ├── dev
    sha256:c9ab59cb1ce11477ca   47 MB  COPY manager . # buildkit              drwxr-xr-x        0:0     220 kB  │   ├─⊕ etc
                                                                              drwxr-xr-x 65532:65532        0 B  │   ├─⊕ home
[Layer Details]────────────────────────────────────────────────────────────── drwxr-xr-x        0:0        0 B  │   ├── lib
                                                                              drwxr-xr-x        0:0        0 B  │   ├── proc
Digest: sha256:c9ab59cb1ce11477cac4d634bb81cf7316c344b50f01a62a8e5ddcf355d5fe drwx------        0:0        0 B  │   ├── root
cf                                                                            drwxr-xr-x        0:0        0 B  │   ├── run
Tar ID: 998c57d00785ccffaf3b308a529c7f816633897097d1ef6519269a8e3c5af59b      drwxr-xr-x        0:0        0 B  │   ├── sbin
Command:                                                                      drwxr-xr-x        0:0        0 B  │   ├── sys
COPY manager . # buildkit                                                     drwxrwxrwx        0:0        0 B  │   ├── tmp
                                                                              drwxr-xr-x        0:0     2.1 MB  │   ├─⊕ usr
[Image Details]────────────────────────────────────────────────────────────── drwxr-xr-x        0:0     1.8 kB  │   └─⊕ var
                                                                              -rwxr-xr-x        0:0     118 kB  ├── ls
Total Image size: 51 MB                                                       -rwxr-xr-x        0:0      47 MB  ├── manager
Potential wasted space: 0 B                                                   -rwxr-xr-x        0:0      67 kB  ├── tail
Image efficiency score: 100 %                                                 -rwxr-xr-x        0:0     1.8 MB  └── test

Count   Total Space  Path

</code></pre>
<p>This file tree confuses me more or less.</p>
<p>Anyway, strange thing is, <code>ls tail manager</code> can't exec, but <code>test</code>can exec.</p>
<p>after I change <code>ENTRYPOINT [&quot;/manager&quot;]</code> to <code>ENTRYPOINT [&quot;/test&quot;]</code>:</p>
<pre><code>[root@master go-docker-test]# docker logs c11
empty
</code></pre>
<p>test is a program built by test.go, I write it myself:</p>
<pre><code>package main

import (
        &quot;fmt&quot;
)
type Per struct {
        Name string
        Age int
}
type Person struct {
        Name string
        Age int
        Lov Per
}

func main() {
        var one Person
        one.Name=&quot;abc&quot;
        one.Age=11
        var two Per
        one.Lov=two
        if one.Lov != (Per{}){
                fmt.Println(&quot;not empty!&quot;)
        }else {
                fmt.Println(&quot;empty&quot;)
        }
}
</code></pre>

HelpMePlease
<p>After reading silh's comment and the kubebuilder <code>Dockerfile</code> again, I somehow solved this problem by adding <code>CGO_ENABLED=0</code> to <code>go build</code>. It changes dynamic linker to static linker.</p>
<pre><code>CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
</code></pre>
<p>At least the <code>no such file or directory</code> error is now gone.</p>
