Docker No such file or directory

PHPz
Release: 2024-02-09 22:18:09
forward
456 people have browsed it

Docker 没有这样的文件或目录

php editor Xiaoxin will give you the answer: When using Docker, sometimes you will encounter the error message "Docker does not have such a file or directory". This error usually means that Docker cannot find the required file or directory when executing the specified command. There may be many reasons for this error, such as the file or directory does not exist, the path is set incorrectly, etc. There are many ways to solve this problem. You can check whether the file or directory exists, confirm whether the path setting is correct, check whether the Docker image is correct, etc. Hope these methods can help you solve this problem.

Question content

I'm trying to write a very simple and straightforward docker file for a golang application. But for some reason when trying to run the image it gives me this error:

exec /app/servertest: No such file or directory

I can't figure out what's wrong with it, searched for similar questions but nothing solved the problem.

This is my dockerfile:

## Build
FROM golang:1.20 AS build

WORKDIR /tmp/build

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

RUN go build -o ./out/serverTest .

## Deploy
FROM golang:alpine

COPY --from=build /tmp/build/out/serverTest /app/serverTest

EXPOSE 8080

ENTRYPOINT ["/app/serverTest"]
Copy after login

I've tried granting x permissions, using cmd instead of entrypoint, changing names/folders, etc...

Any idea where the problem might be?

Solution

Try building:

CGO_ENABLED=0 go build -o ./out/serverTest .
Copy after login

The above is the detailed content of Docker No such file or directory. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!