Search code examples
dockercreate-react-app

Not getting any response from React application run with docker-compose up


Compiled successfully!
web_1  |
web_1  | You can now view react-docker-app in the browser.
web_1  |
web_1  |   Local:            http://localhost:3000
web_1  |   On Your Network:  http://172.18.0.2:3000
web_1  |
web_1  | Note that the development build is not optimized.
web_1  | To create a production build, use yarn build.
web_1  |

Running docker-compose up gave the output above, but when I try to connect to the server on my browser, I don't get anything:

The server at 172.18.0.2 is taking too long to respond.

Firefox can’t establish a connection to the server at localhost:3000.

I entered the port and address:

http://172.18.0.2:3000/

http://localhost:3000/

I am not getting any error message. I am using a boilerplate project I created with npx create-react-app docker-app.

Is there something wrong.

Here's my dockerfile:

version: '3'
services:
  web: 
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports: 
      - "3000:3000"
    stdin_open: true
    tty: true
    volumes:
      - /app/node_modules
      - .:/app

Dockerfile.dev:

FROM node:11.10.1-alpine

WORKDIR '/app'

COPY package.json .
RUN npm install

COPY . .

CMD ["npm", "run", "start"]

Solution

  • I was using Docker Toolbox on Windows 8, because I couldn't use the latest Docker on Windows 10, so the ip was http://192.168.99.100:3000/ It seems that Docker Toolbox works a bit differently, because it has its own ip address.