Docker build stuck

I try to run my Dockerfile on my local machine, and it is running perfectly. But when I tried to docker build on my VPS, it was stuck when downloaded the last package.

I assume this because can’t export to the docker image. Both VPS (512ram & 10G storage) and my local machine had the same version and build version, and the other docker image worked but not on this project (I tried to remove the other docker image, still not working)

FROM golang:1.20.4

WORKDIR /go/src/app

COPY . .

RUN go build -o main main.go

CMD ["./main"]

Can someone explain what could possibly be the problem?

Did you try to run htop in a second connection to see memory usage? Did you try with a 1GB RAM VPS?

I haven’t tried to upgrade my VPS, I am afraid to make the bill high.

I tried to remove unused services that took some memory usage like Postgres (psql) and it worked, I guess I need to learn how to calculate my resource. Thanks