![](/img/trans.png)
[英]Cannot connect proxy_server localhost:3000 to nginx config file (docker-compose project)
[英]docker-compose not serving Nuxt.js website under localhost:3000
雖然我知道該課程是針對后端應用程序的,但我嘗試為前端 Nuxt.js 應用程序制作 docker-compose.yml 和 Dockerfile。 我的 docker-compose.yml 文件如下所示:
version: '2.4'
services:
web:
build: .
volumes:
- .:/app
- /app/node_modules/
ports:
- 3000:3000
任何我的 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.
我在這里做錯了什么?
你的 cmd 應該是
CMD ["yarn", "dev"]
在 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.