Hi guys. I’m new to this community and to docker. I’ve started learning this wonderful platform one week ago, learning the basics (containers, images, how to build, some commands etc).
I was following this guide: The Docker Handbook – Learn Docker for Beginners and tried to build an image for a frontend project with react and tailwind with vite (just for learn how to do it). After some tries and change some commands i was able to build an image and start a container from that image but when i try to connect from local in chrome i receive an error: “This site can’t be reached, The connection was reset.”
This is the dockerfile:
FROM node:lts
EXPOSE 3000
# Set the working directory
WORKDIR /home/node/app
# Copy package files and install dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install
# Copy the rest of the application code
COPY . .
# Adjust permissions
RUN chown -R node:node /home/node/app
RUN chmod -R u+w /home/node/app
# Switch to non-root user
USER node
CMD ["npm", "run", "dev"]
this is the command that i used to build the image:
Where did you look for the error messages? The guide also shows how you can check the error messages in the container. Connection reset means the port was open, but the application didn’t listen on that port.
solved. Through this command "docker exec -it “container_id” /bin/sh and then curl http://localhost:3000, like you said i verified that the application wasn’t listening on the 3000 port. I solved this by edit vite.config file, by adding some configuration.