Search code examples
dockerastrojs

Unable to access port Astro app at default port 4321 in Docker container


I have setup the basic Astro skeleton app (with sample data), ran the script "npm run dev" locally and was able to access the site through localhost:4321.

When I tried to create a container from that and ran it, I was unable to access the site at localhost:4321. Below is the Dockerfile I'm using:

FROM node:18-alpine
WORKDIR /app

COPY package.json package-lock.json ./

COPY . .

RUN npm install

EXPOSE 4321

CMD [ "npm", "run", "dev" ]

and the commands I ran to build and run the container (respectively):

docker build -t personal-site-astro .
docker run -p 4321:4321 personal-site-astro

Solution

  • Sorry I forgot I had this question still up. I managed to get it working by using the map 4322:4321. For some reason, Docker on my system doesn't like port 4321.