Introducing Docker Build Checks: Optimize Dockerfiles with Best Practices
Docker Desktop 4.33 adds Build checks, which evaluate Dockerfiles against codified best-practice rules during `docker build` and report warnings. Because the checks are part of the build itself, they also consider build arguments and base images rather than only linting the text. `docker build --check` runs the evaluation in under a second without executing the build, and `# check=error=true` makes warnings fail CI. Individual rules can be disabled with `# check=skip=...`, and the checks also work with multi-stage builds, Bake and Docker Build Cloud.
Related posts
- Docker Bake is Now Generally Available in Docker Desktop 4.38!
Docker mediumAdeptDocker Bake, a declarative build orchestration tool for BuildKit, is now generally available in Docker Desktop 4.38. It replaces chains of `docker build` commands with an HCL (or Compose-compatible) file defining targets, groups, variables and matrix builds, and parallelizes and deduplicates work. The GA release adds automatic deduplication of shared build-context transfers, entitlements (`--allow` for host networking, insecure mode, filesystem paths and SSH), composable structured attributes for attest/cache/output/secret/ssh that can be inherited and overridden, Terraform-style variable validation blocks, and a `--list` option for querying targets and variables.
- Master Docker and VS Code: Supercharge Your Dev Workflow
Docker mediumAdeptDocker containers paired with VS Code's Docker extension give every developer an identical environment and remove "works on my machine" bugs. The walkthrough builds and runs annotated Dockerfiles for an Express app and a Flask app, then manages containers from the extension's sidebar. It also covers attaching the debugger to Node's inspect port (9229) and to multiple services under Compose, and using Dev Containers for shared team environments. Tips include trusted base images, scanning with Docker Scout or Trivy, `.dockerignore` and multi-stage builds, and a GitHub Actions snippet that builds, tests and pushes images.
- Docker Best Practices: Understanding the Differences Between ADD and COPY Instructions in Dockerfiles
Docker mediumAdeptDockerfile COPY only copies files and directories from the build context into an image layer. ADD can do the same, but it also downloads URLs and automatically extracts local and remote archives. That extra behaviour brings flexibility, but also unpredictability and security risk from external content, so COPY is the sensible default and ADD should be reserved for cases that need fetching or extraction. Both instructions also work with remote build contexts such as Git repositories, remote tarball URLs and OCI images, with COPY still scoped to the context.
- Accelerate Your Docker Builds Using AWS CodeBuild and Docker Build Cloud
Docker mediumAdeptOffloading container image builds from AWS CodeBuild to Docker Build Cloud addresses three common CI bottlenecks: undersized build machines, no persistent layer cache in clean CI environments, and slow emulated multi-architecture builds. A buildspec.yml installs the latest Buildx, logs in to ECR and Docker with a PAT from Secrets Manager, selects a cloud builder, and runs `docker buildx build --platform linux/amd64,linux/arm64 --push` straight to ECR. On a 2 vCPU/3GB CodeBuild instance, the build dropped from 5:59 for an AMD64-only local build to 1:04 for a native AMD64+Arm64 build, using 16 vCPU/32GB builders and a 200 GiB shared cache.
- Debug Docker Builds with Visual Studio Code
Docker mediumAdeptDocker Buildx 0.29+ adds a Dockerfile build debugger. It is integrated into VS Code through the Docker DX extension and configured with a launch.json entry of type "dockerfile". You can set breakpoints on instructions like RUN, inspect build-time variables such as ARG, ENV and workdir, and browse the in-progress image's file system and text file contents. Running `exec` in the Debug Console opens a throwaway shell inside the image at the paused step, and changes reset when you step forward. The debugger implements the Debug Adapter Protocol, so it also works in Neovim (nvim-dap-docker) and JetBrains IDEs via LSP4IJ.