Some executable files show "no such file or directory" after run in docker, while some are not
This is my Dockerfile:
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY ls .
COPY tail .
COPY test .
COPY manager .
ENTRYPOINT ["/manager"]
after
[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
it shows:
exec /manager: no such file or directory
I'm pretty sure it is there. I use dive to see it:
[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
This file tree confuses me more or less.
Anyway, strange thing is, ls tail manager
can't exec, but test
can exec.
after I change ENTRYPOINT ["/manager"]
to ENTRYPOINT ["/test"]
:
[root@master go-docker-test]# docker logs c11
empty
test is a program built by test.go, I write it myself:
package main
import (
"fmt"
)
type Per struct {
Name string
Age int
}
type Person struct {
Name string
Age int
Lov Per
}
func main() {
var one Person
one.Name="abc"
one.Age=11
var two Per
one.Lov=two
if one.Lov != (Per{}){
fmt.Println("not empty!")
}else {
fmt.Println("empty")
}
}
Comments
Post a Comment