#Run react app using docker

1 messages · Page 1 of 1 (latest)

odd wind
#

I am trying to use Docker to run a react app to test bun.

So basically my Dockerfile is:

FROM oven/bun:latest #V1.0.0

COPY ./react-app .

RUN apt-get update && apt-get install -y curl unzip && \
    curl -fsSL https://bun.sh/install | bash && \
    bun install

CMD ["bun", "run", "start"]

The issue is that when the container starts I get the following error:
"Something is already running on port 3000."

The package.json is:

{
  "name": "react-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.15.0",
    "react-scripts": "5.0.1"
  },
  "scripts": {
    "start": "react-scripts start"
  }
}

And docker-compose.yml is:

version: '3.8'

services:
  bun-test:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"

Thanks 🙂

odd wind
#

Run react app in docker

#

Run react app using docker

slate trout
#

I would try restarting your computer just to make sure every program you may have opened is closed. If that dont work chances are good that you have some service that is running on that port

Best thing to do if that is the case is change the port on the host side to something thats available

smoky copper
#

If no containers or images are running, and you've already tried to docker kill all instances that run on 3000 (or in general), I'd recommend checking what context you're using (docker context) especially if you use Docker Desktop.

simple jackal
#

im guessing you have react and bun running on 3000? try changing either the bun or react port, they may also be sharing a process.env

#

also, you are using the bun docker image, so you dont need to install curl/unzip/bun.. its pre-installed and setup. just do

FROM oven/bun:latest #V1.0.0

COPY ./react-app .

CMD ["bun", "start"]
odd wind
simple jackal
#

how are you setting the ports? did you re-set dockers process.env after you made the changes? this sounds like user error

odd wind
#

@simple jackal in the docker-compose 3000:3000