Docker-Compose build failed

60 Views Asked by At

I have golang + postgresql docker-compose. Help me please with error below.

docker-compose.yml

version: '3.8'
networks:
  net_mastertest:
   driver: bridge
   ipam:
    config:
    - subnet: 127.0.0/24
services:
  server:
    build: ./
    command: ./server
    ports:
      - 8000:8000
    depends_on:
      - db
    networks:
      - net_mastertest

  db:
    restart: always
    image: postgres:latest
    env_file:
      - .env
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    ports:
      - 5555:5555
    networks:
      - net_mastertest

Dockerfile

FROM golang:1.20

WORKDIR /app

RUN go version
ENV GOPATH=/

COPY ./ ./

RUN go mod download
RUN go build -o server ./main.go
CMD ["./server"]

I receive error with such config:

  • => ERROR [4/5] RUN go mod download 60.3s

[4/5] RUN go mod download: #0 60.24 go: github.com/astaxie/[email protected]: Get "https://proxy.golang.org/github.com/astaxie/beego/@v/v1.12.3.mod": dial tcp: lookup proxy.golang.org on 192.168.1.1:53: read udp 172.17.0.3:45655->192.168.1.1:53: i/o timeout


failed to solve: executor failed running [/bin/sh -c go mod download]: exit code: 1*enter image description here

1

There are 1 best solutions below

0
Drarig29 On

I found something which is closely related:

https://github.com/projectdiscovery/httpx/discussions/658

First, check if curl https://proxy.golang.org works in your setup. You might have something misconfigured.

If the curl command doesn't work, you can try to disable going through proxy.golang.org:

export GOPROXY=direct

And if it still doesn't work, you can try to restart Docker. If you are on a Linux OS with systemd, use the following command:

systemctl restart docker