I have tried looking through the forum and found these posts, 1, and others on the same problem, but there was no posted answer.
I looked through a StackOverflow post on the issue, but it is for Dockerfiles not docker-compose files. I followed the answer for this post, but it did not work.
FROM golang:latest
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o scraper
CMD ["scraper"]
This is what my file structure looks like:
scraper
┣ Dockerfile
┣ README.md
┣ default.conf
┣ go.mod
┣ go.sum
┣ helper.go
┣ justfile
┣ main.go
┣ scraper.go
┣ server.go
┗ type.go
docker-compose.yaml
Running docker-compose up --build is what caused this error to appear and running docker-compose up results in the routes image to exit with code 0. How would I fix this issue, and is there a way to use the docker-compose file without the Dockerfile?
edit: running docker build --file Dockerfile . in the scraper directory does work.
I got the same issue with docker compose up --build. I am running docker version 27.4.1 on docker desktop. The link you have doesn’t lead to any article.
I installed through homebrew or docker desktop. I don’t remember.
Then I moved the topc to the Docker Desktop category. I’m not sure the issue is related to Docker Desktop and not just compose, but untl we find out, it seemed better then “General”. Since I have Mac too, I created a smaller test project. Please, try this too
WARN[0003] Found orphan containers ([routes proxy scraper]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[+] Running 1/0
✔ Container backend-test-1 Created 0.0s
Attaching to test-1
test-1 exited with code 0
I have just noticed you have the build keywords for two compose services. The one I tested is the one that works, but you have no Dockerfile in the root directory. So the other service will fail.
The failing service should be shown above the error message
How would restarting a container solve en error during building an image? Just run what you wanted originally. But if the other image was already built properly, you don’t even need to do anything.
I am confused. Are the other services not the issue? I thought restarting the container might fix it.
If I ran what I wanted originally, which was docker compose up, I would get an exit 0 for the routes service. How would I fix that?