
本仓库构建并发布基于官方Alpine Node.js镜像(node:v${VERSION}-alpine)的Node.js镜像,专为前端资源构建和编译优化。这些镜像设计用于构建JavaScript、CSS及其他前端资源,而非在生产环境运行Node.js应用。支持ARM64和x86_64主机架构,可无缝集成Webpack、Vite、Rollup等现代构建工具。
拉取Node.js Docker镜像
要获取特定版本的Node.js镜像,使用:
bashdocker pull mxmd/node:v<VERSION>
其中:
<VERSION> 为所需Node.js主版本(如 v14、v16、v18、v20、v22)。-full(如 v18-full)。例如,拉取Node.js 18镜像:
bashdocker pull mxmd/node:v18
拉取带Chrome/Puppeteer支持的Node.js 18镜像:
bashdocker pull mxmd/node:v18-full
可用镜像版本及Docker Hub链接:
基础版本:
Chrome支持版本:
Gulp专用版本:
镜像类型
标准镜像(如 18、20、22):包含Node.js及前端资源编译所需的核心构建工具和依赖:
Full镜像(带 -full 后缀):包含标准镜像的所有内容,另加:
Gulp镜像:包含标准镜像的所有内容,另加预安装的Gulp:
gulp4 变体:预安装Gulp 4.0.0,适用于遗留项目gulp5 变体:预安装Gulp 5.0.0,适用于现代项目gulp4-full 和 gulp5-full 变体:结合Gulp安装与Chrome/Puppeteer支持使用Docker Compose
可将Node.js镜像集成到前端构建工作流中,以下是常见用例:
基本构建服务
yamlservices: frontend-build: image: mxmd/node:v18 container_name: frontend-builder working_dir: /app volumes: - .:/app - /app/node_modules environment: - NODE_ENV=production # 对Linux主机至关重要 - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} command: yarn && yarn build
带Chrome/Puppeteer测试的构建
yamlservices: frontend-build-with-testing: image: mxmd/node:v18-full container_name: frontend-builder-full working_dir: /app volumes: - .:/app - /app/node_modules environment: - NODE_ENV=production - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} shm_size: 1gb command: | sh -c "yarn && yarn build && yarn test:e2e"
带Watch模式的开发
yamlservices: dev-server: image: mxmd/node:v20 container_name: dev-server working_dir: /app volumes: - .:/app - /app/node_modules ports: - "3000:3000" - "5173:5173" # Vite开发服务器 environment: - NODE_ENV=development - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} command: yarn && yarn dev
多阶段构建流水线
yamlservices: install-deps: image: mxmd/node:v18 working_dir: /app volumes: - .:/app - node_modules:/app/node_modules environment: - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} command: yarn install --frozen-lockfile build-assets: image: mxmd/node:v18 working_dir: /app volumes: - .:/app - node_modules:/app/node_modules - build_output:/app/dist environment: - NODE_ENV=production - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} command: yarn build depends_on: - install-deps run-tests: image: mxmd/node:v18-full working_dir: /app volumes: - .:/app - node_modules:/app/node_modules environment: - NODE_ENV=test - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} shm_size: 1gb command: yarn test depends_on: - install-deps volumes: node_modules: build_output:
Gulp专用构建
yamlservices: gulp-build: image: mxmd/node:v18-gulp4 container_name: gulp-builder working_dir: /app volumes: - .:/app - /app/node_modules environment: - NODE_ENV=production - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} command: | sh -c "npm install && gulp build"
带SSH密钥的私有仓库访问
yamlservices: build-with-ssh: image: mxmd/node:v20 working_dir: /app volumes: - .:/app - /app/node_modules - ~/.ssh:/home/node/.ssh-copy:ro # SSH密钥以只读方式挂载 environment: - NODE_ENV=production - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} command: | sh -c "yarn install && yarn build"
完整开发环境
yamlservices: frontend: image: mxmd/node:v20-full container_name: frontend-dev working_dir: /app volumes: - .:/app - /app/node_modules - ~/.ssh:/home/node/.ssh-copy:ro ports: - "3000:3000" - "5173:5173" - "8080:8080" environment: - NODE_ENV=development - HOST_USER_UID=${HOST_USER_UID:-1000} - HOST_USER_GID=${HOST_USER_GID:-1000} - CHOKIDAR_USEPOLLING=true # 容器内文件监控 shm_size: 1gb stdin_open: true tty: true command: bash # 交互式开发shell
重要注意事项:
-full镜像建议设置shm_size: 1gb/home/node/.ssh-copy时,入口脚本会自动配置CHOKIDAR_USEPOLLING=true主机需设置以下环境变量:
bashHOST_USER_GID HOST_USER_UID
设置环境变量
在macOS上,可在~/.extra或~/.bash_profile中设置。
获取HOST_USER_UID:
bashid -u
获取HOST_USER_GID:
bashid -g
在主机上设置:
bashecho "export HOST_USER_GID=$(id -g)" >> ~/.bash_profile && echo "export HOST_USER_UID=$(id -u)" >> ~/.bash_profile && echo "export DOCKER_USER=$(id -u):$(id -g)" >> ~/.bash_profile
以下是 mxmd/node 相关的常用 Docker 镜像,适用于 Web 开发、API 服务、实时应用 等不同场景:
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。


探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务