问题库 Linux / Docker how-to

.dockerignore 应该写什么

快速答案

排除 node_modules、日志、构建产物和本地密钥,减少构建上下文。

bash
node_modules
dist
.env
*.log

使用要点

  • 先分清容器、镜像、卷和 Compose 服务名,避免对错对象执行命令。
  • 删除、重建或清理资源前,先确认数据是否在卷或挂载目录里。

相关内容