Skip to main content
DevTools24

Construtor de Dockerfile

Construa Dockerfiles visualmente com predefinições para linguagens populares. Reordene comandos e siga melhores práticas.

Presets:
FROM node:20-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000

CMD ["node", "index.js"]

Best Practices

  • • Use specific image tags instead of :latest for reproducibility
  • • Combine multiple RUN commands with && to reduce layers
  • • Copy package.json first, then npm install, then copy source for better caching
  • • Use multi-stage builds for smaller production images
  • • Run as non-root user for security

Dockerfiles - Detalhes Técnicos

A Dockerfile is a text file containing instructions to build a Docker image. Each instruction creates a layer, so optimizing the order and combining commands reduces image size and build time.

Alternativa via Linha de Comando

# Build Docker image\ndocker build -t my-app .\n\n# Run container\ndocker run -p 3000:3000 my-app\n\n# Multi-stage build\n# See Dockerfile reference for advanced patterns

Referência

Ver Especificação Oficial