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
- VScode: How to Solve golong plug-in install Error
- Docker Create tomcat Error standard_init_linux.go:211: exec user process caused “no such file or directory”
- Failed to copy files Error processing tar file [How to Solve]
- Docker run Error: container_linux.go:235: starting container process caused “process_linux.go:258: appl
- package golang.org/x/net/XXX: unrecognized import path “golang.org/x/net/xxx“…
- [Solved] docker failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition
- Docker Build Error: Failed to get D-Bus connection: Operation not permitted [Solved]
- MAC: How to modify the docker container error [screen is terminating]
- [Solved] Kibana Error: Kibana server is not ready yet
- [Solved] Docker startup container error: permission denied””: unknown.
- [environment] docker: error response from daemon: OCI runtime
- How to Solve k8s Nodal issues: /sys/fs/cgroup/memory/docker: no space left on device\““: unknown.
- [Solved] Docker Startup Error: panic: runtime error: invalid memory address or nil pointer dereference
- [Solved] Vite Project jenkins Auto Package Error: failed to load config from ../vite.config.js You installed esbuild on
- [Solved] kubelet Startup Error: cannot find network namespace for the terminated container
- [Solved] Installing github.com/uudashr/gopkgs/v2/cmd/[email protected] FAILED和cannot install, GOBIN must be an ab
- Nginx Container Error: nginx: [emerg] mkdir() “/var/cache/nginx/client_temp“ failed (13: Permission denied)
- [Solved] docker Error: bridge docker0 failed: exchange full
- How to Fix ERROR Couldn’t connect to Docker daemon at http+docker://localunixsocket