Docker Init: Generating Dockerfiles Automatically
The docker init command scaffolds Docker configuration files for your project automatically. It detects your application type and generates optimized Dockerfiles, compose files, and .dockerignore files for your Breeze deployments.
Prerequisites
Ensure you have Docker Desktop or Docker Engine 25+ installed:
docker --version
# Docker version 25.0.0 or later required
Running Docker Init
Navigate to your project directory and run:
cd /home/user/myproject
docker init
The interactive wizard asks about your application:
- Application platform (Node.js, Python, Go, Rust, etc.)
- Application entrypoint
- Listening port
Generated Files
Docker init creates these files:
.
├── Dockerfile # Multi-stage build optimized for production
├── compose.yaml # Docker Compose configuration
├── .dockerignore # Excludes unnecessary files
└── README.Docker.md # Docker-specific documentation
Example Generated Dockerfile for Node.js
FROM node:20-alpine AS base
WORKDIR /app
COPY package*.json ./
FROM base AS deps
RUN npm ci --omit=dev
FROM base AS build
RUN npm ci
COPY . .
RUN npm run build
FROM base AS final
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]
Tips
- Review and customize the generated files for your specific needs
- The generated Dockerfile uses multi-stage builds for smaller images
- Add application-specific environment variables to the compose file
- Run
docker compose upimmediately after init to test