[英]docker-compose not serving Nuxt.js website under localhost:3000
While I know that the course was meant for backend apps, I've tried making a docker-compose.yml and Dockerfile for a frontend Nuxt.js app.虽然我知道该课程是针对后端应用程序的,但我尝试为前端 Nuxt.js 应用程序制作 docker-compose.yml 和 Dockerfile。 My docker-compose.yml file looks like this:
我的 docker-compose.yml 文件如下所示:
version: '2.4'
services:
web:
build: .
volumes:
- .:/app
- /app/node_modules/
ports:
- 3000:3000
Any my Dockerfile:任何我的 Dockerfile:
FROM node:13.0-alpine
ENV NODE_ENV=development
WORKDIR /app
EXPOSE 3000
COPY package.json yarn.lock* ./
RUN apk add --no-cache --virtual .build-deps alpine-sdk python \
&& yarn && yarn cache clean \
&& apk del .build-deps
ENV PATH=./node_modules/.bin/:$PATH
COPY . .
CMD ["nuxt"]
When I run this with docker-compose up
, my application builds and starts properly though the nuxt
CMD, but when I go to http://localhost:3000 the app isn't online. When I run this with
docker-compose up
, my application builds and starts properly though the nuxt
CMD, but when I go to http://localhost:3000 the app isn't online.
What am I doing wrong here?我在这里做错了什么?
your cmd should be你的 cmd 应该是
CMD ["yarn", "dev"]
in docker compose you can add the line command and use it for apply dev or start when you need.在 docker compose 中,您可以添加行命令并在需要时将其用于应用开发或启动。
version: '3'
services:
web:
build: .
volumes:
- .:/app
- /app/node_modules/
ports:
- 3000:3000
command: yarn dev
# or
# command: yarn build && yarn start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.