iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
These seven Docker habits—attributed to Docker Captains in posts published between June and August 2025—help engineers initialize projects, manage image contents and build context, clean up disk usage carefully, and reduce container privileges. Treat generated configuration as a draft, review cleanup targets before deleting data, and test security changes against the needs of the application.
1. Start a project with docker init
When setting up a project, docker init can generate a starting set of Docker files: a Dockerfile, .dockerignore, compose.yaml, and README.Docker.md. Docker Captain Mohammad-Ali A’râbi recommended the command in a post dated June 16, 2025, reproduced by Container Security.
Review the generated files before using them. They may need changes for your language, build process, environment variables, ports, and deployment requirements; generated configuration is a convenient starting point, not a guarantee of production readiness.
Recommended Free Tools
2. Prune Docker resources without deleting data you need
docker system prune -a --volumes can reclaim disk space, but the --volumes flag makes this a potentially destructive cleanup. Docker Captain Rafael Pazini promoted the command on June 23, 2025, and the reproduced post warned that unused volumes would be removed. A volume that Docker considers unused may still contain data you want to keep.
#1 Best Overall
-abroadens pruning to all unused images, rather than only dangling images.--volumesincludes unused volumes in the cleanup.
Read the confirmation prompt and check which resources will be removed before approving. Do not run the command blindly on a machine where volumes may hold databases, development state, or other valuable data. Pazini’s reported 8 GB cleared on his Mac was a personal anecdote, not a typical or guaranteed result.
3. Separate build and runtime stages
A multi-stage Dockerfile uses one stage to build an application and a later stage to assemble the runtime image. This can keep compilers, build tools, and intermediate files out of the final image when they are not needed to run the application. Docker Captain Karan Verma recommended the approach on June 30, 2025.
Choose what crosses from the build stage into the runtime stage deliberately. Multi-stage builds do not automatically make every image smaller or faster: the result depends on the application, dependencies, and Dockerfile.
Free tools Windows power users keep installed
One-click scans. No signup required.
4. Pin a suitable base-image version—and plan updates
Choose a base image that fits the application, and specify a version rather than relying on a moving tag. A lightweight image may reduce the amount of software in the final image, while a pinned version makes the starting point more explicit and can improve reproducibility. Docker Captain Sergio Lopes recommended lightweight, official, version-pinned images on July 14, 2025.
Rank #3
There is a maintenance trade-off: a pin does not update itself when maintainers publish a newer version. Establish how you will review and adopt updates, and test changes for compatibility. The smallest available image is not automatically the right choice if it makes dependencies, debugging, or updates harder for your workload.
5. Use Docker Scout as a review aid
Run docker scout quickview to review information about an image, including vulnerability and dependency or base-image details. Docker Captain Khushboo Verma recommended it on July 21, 2025. The command can help surface issues to investigate, but its findings depend on the image scanned and the vulnerability data available. A scan is not proof that an image is secure or free of vulnerabilities.
Rank #4
6. Keep irrelevant files out of the build context
A .dockerignore file tells Docker which paths to exclude from the build context. A smaller, focused context can avoid sending irrelevant files to the builder and can help prevent local or sensitive files from being available during a build. Docker Captain Anjan Kumar Reddy Ayyadapu recommended this practice on July 29, 2025, with examples including .git/, node_modules/, test files, and debug logs.
Decide exclusions based on how the project builds. For example, excluding node_modules/ may make sense when dependencies are installed inside the build, but not if the build relies on files from that directory. Check that required source files and build inputs remain available; no single ignore list fits every project.
Best Value
7. Drop unneeded container capabilities
Linux capabilities split some root-level privileges into narrower permissions. Docker’s --cap-drop and --cap-add options let you remove capabilities and add back those the workload actually needs. Docker Captain Mohammad-Ali A’râbi recommended limiting capabilities on August 7, 2025.
Apply least privilege, then test the application under the resulting settings. The required capability set is application-specific: dropping a capability can break a workload, while adding one without a demonstrated need weakens the restriction. Do not copy an example capability setting without checking what the application does.
How the seven habits fit together
Project initialization and multi-stage builds shape the configuration and contents of an image. Base-image choices affect included software and the work needed to keep versions current; .dockerignore controls what enters the build context. Scout adds a way to inspect an image, while careful pruning addresses accumulated resources and capability restrictions limit what a running container can do.
The tips were attributed to named Docker Captains in posts dated June through August 2025 and reproduced by Container Security. Docker’s indexed LinkedIn post describes the series as guidance for leaner images, security, and improved workflows: Docker’s post.
Further learning
For a structured introduction to Docker, Docker’s educational resources list Docker Deep Dive, 2024 Edition by Nigel Poulton. It is optional; the seven practices above can be applied without it.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

