0

I have a Dockerfile and docker-compose.yml that I developed on OSX. It looks like this:

cat Dockerfile:

FROM alpine:3.7

ADD ./app /home/app/
WORKDIR /home/app/

RUN apk add --no-cache postgresql-dev gcc python3 python3-dev musl-dev && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --upgrade pip setuptools && \
    rm -r /root/.cache && \
    pip3 install -r requirements.txt

EXPOSE 5000

ENTRYPOINT ["python3", "app.py"]

cat docker-compose.yml:

version: "3"
services:
  web:
    build: .
    ports:
      - "5000:5000"
    volumes:
      - ./app/:/home/app/
    depends_on:
      - db
  db:
    image: postgres:10
    environment:
      - POSTGRES_USER=testusr
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=testdb
    expose:
      - 5432

I then start via: docker-compose up --build -d and open the web browser on port 5000, it shows a form (as expected). Again, this works perfect on OSX.

However, on Windows 10 it just shows a blank page. And docker port <CONTAINER> shows 5000/tcp -> 0.0.0.0:5000 so I know it's bound to the right port.

Additionally, if I docker logs -f <python container> it doesn't show the request ever getting to the container. Normally a new line is printed (w/status code) for each flask/nginx response. In this case it looks like it's not even getting to the python application container.

So, any idea why this doesn't work on Windows?

namokarm
  • 668
  • 1
  • 7
  • 20
mr-sk
  • 13,174
  • 11
  • 66
  • 101
  • https://stackoverflow.com/questions/40746453/how-to-connect-to-docker-host-from-container-on-windows-10-docker-for-windows – arunp9294 Jul 11 '18 at 19:41

1 Answers1

0

So the answer is that you have to use docker-machine ip to see what IP the container is bound to. It doesn't just bind to localhost/127.0.0.1 like it does on OSX.

mr-sk
  • 13,174
  • 11
  • 66
  • 101