I’m trying to run my vite+react app using the docker container, the code is running fine but unfortunately, it’s not opening in localhost 3000
DockerFile
FROM node:18-alpine
EXPOSE 3000
WORKDIR /react-vite-app
COPY package.json .
RUN yarn install
COPY . .
CMD [ "yarn","build"]
docker-compose.yml
version: "3.8"
services:
reactapp:
build: ./dir
container_name: react_vite_app
ports:
- '3000:3000'
Is something missing, If something is wrong please help me to fix this
3
Answers
my settings
Dockerfile
package.json
I had the exact same issue from the same config, I found the solution here :
https://stackoverflow.com/a/68595302/16795034
Set port in vite config to 3000
Also run docker like this