docker vue 正确方式

安装node.js

npm是node的包管理工具

本地下载vue

npm init vue@latest

或者

npm create vue

然后创建项目名称test,cd进去
编写docker-compose.yaml 文件

version: "3.8"

services:
  vue:
    image: node:20
    container_name: vue-app
    working_dir: /app
    volumes:
      - .:/app               # 当前目录必须包含 package.json
      - /app/node_modules
    ports:
      - "5173:5173"          # 或 8080:8080,如果你用 vue-cli
    command: sh -c "npm install && npm run dev -- --host"
    restart: unless-stopped

确保可以访问网络,
然后启动docker-compose,主机访问127.0.0.1:5173

posted @ 2025-07-14 15:04  学不会xuebuhui  阅读(6)  评论(0)    收藏  举报
Language: javascript //图片预览