Scene
In the process of packaging the golang application into a docker image, execute the following command
docker run -it -P --name docker_client -m 1024m --net host docker_client:1.0
After execution, the server reported this error
standard_init_linux.go:190: exec user process caused "exec format error"
It’s useless to follow the online method. I can run normally on the virtual machine. I’ll look at my dockerfile carefully later
FROM golang:alpine
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
# Create an apps directory in the container root directory
WORKDIR /build
# Copy the go_docker_demo1 executable from the current directory
COPY . .
# Compile our code into a binary executable app
RUN go build -o app .
# Move to the /dist directory where the generated binaries are stored
WORKDIR /dist
# Copy the binaries from the /build directory to here
RUN cp /build/app .
# Expose the port
EXPOSE 8080
# The command to run the golang program
CMD ["/dist/app"]
It is found that the goarch parameter is AMD64. Check the relevant version of the server later
docker version
#check the version of the docker
A problem was found in the output information. One line of parameters is arm64
OS/Arch: linux/arm64
So I modified the dockerfile file
FROM golang:alpine
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=arm64
# Create an apps directory in the container root directory
WORKDIR /build
# Copy the go_docker_demo1 executable from the current directory
COPY . .
# Compile our code into a binary executable app
RUN go build -o app .
# Move to the /dist directory where the generated binaries are stored
WORKDIR /dist
# Copy the binaries from the /build directory to here
RUN cp /build/app .
# Expose the port
EXPOSE 8080
# The command to run the golang program
CMD ["/dist/app"]
After rebuilding the dockerfile image, it will run normally.
Read More:
- How to Solve Docker Run Error: standard_init_linux.go:219: exec user process caused: exec format error
- Docker Create tomcat Error standard_init_linux.go:211: exec user process caused “no such file or directory”
- Docker run Error: container_linux.go:235: starting container process caused “process_linux.go:258: appl
- Cannot start container 39f96c64a9c6: [8] System error: exec format error
- [Go] Solve the problem of exec: “gcc” executable file not found in %PATH% error when using cgo
- Mac Appium Error: Error executing adb Exec. Original error…
- [Solved] scala Error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exe
- [Solved] docker Error response from daemon OCI runtime create failed container_linux.go380
- [Solved] Hive Error: FAILED: Execution Error, return code 3 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask
- Hive Error: FAILED: RuntimeException Error loading hooks(hive.exec.post.hooks): java.lang.ClassNotFoundException: org.apache.atlas.hive.hook.HiveHook
- [Solved] Golang Error: main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT
- Solution of socket write error caused by pressing F5 to refresh page by ehcache user
- [Solved] Error running ‘go build myfir_go_project‘: Cannot run program
- Kill Tomcat process in windows and Linux environment (solve the problem of other ports being occupied)
- Go declares that the local variable does not use command line arguments. Main. Go: 4:6: a declared but not used
- Caused by: java.net.SocketException: Software caused connection abort: socket write error
- TypeError: unsupported format string passed to numpy.ndarray.__format__
- [Solved] .\main.go:3:6: missing function body .\main.go:4:1: syntax error: unexpected semicolon or newline be
- [Solved] Error downloading standard development IDs for MRPC. You will need to manually split your data.
- [Solved] go cobra Error: required flag(s) “pkg-name” not set