title: dial tcp 127.0.0.1:8000: connect: connection refused golang docker containers
body: <p>I am trying to make an http request from one project to another both using GO. The project that is making the request has the following dockerfile:</p>
  <pre><code>FROM golang:alpine as builder
  WORKDIR /build
  COPY . .
  RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags &quot;-static&quot;' -o main .
  FROM scratch
  WORKDIR /app
  COPY --from=builder /build .
  CMD [&quot;./main&quot;]
  </code></pre>
  <p>The project that is waiting for the request is running on localhost:8000 and it has the following dockerfile:</p>
  <pre><code>FROM golang:1.13.8 AS build-env
  ADD . /dockerdev
  WORKDIR /dockerdev
  RUN go get -d -v ./...
  RUN go build -o /server
  # Final stage
  FROM debian:buster
  EXPOSE 8000
  WORKDIR /
  COPY --from=build-env /server /
  CMD [&quot;/server&quot;]
  </code></pre>
  <p>When I make</p>
  <pre><code>resp, err := http.Post(&quot;http://localhost:8000/orders&quot;, &quot;application/json&quot;, bytes.NewBuffer(requestBody))
  </code></pre>
  <p>it gives me the following error</p>
  <blockquote>
  <p>dial tcp 127.0.0.1:8000: connect: connection refused</p>
  </blockquote>
  <p>I am new to docker so any improvements are welcome!</p>