Review and improve Dockerfiles
Ask Docker's assistant to explain a Dockerfile, shrink the image, fix build errors or suggest safer base images.
DifficultyBeginner
Setup timeUnder 1 hour
CategoryIT & DevOps
The use case
Dockerfiles get copied between projects and pick up bloat and bad habits: running as root, huge base images, no layer caching. Gordon, Docker's AI assistant in Docker Desktop and the CLI, can explain a Dockerfile, suggest changes such as multi-stage builds or smaller bases, help with failed builds and answer container questions using local context. It can make changes after you approve them. A developer still rebuilds the image, runs tests, and checks that the new base image is supported and scanned before shipping.
Example workflow
- Open the project and ask the assistant to review the Dockerfile
- Read suggested changes and the reasons
- Approve edits you agree with
- Rebuild and run tests
- Scan the image before pushing
Tools
- Docker Desktop
- Gordon
- Docker Scout
Risks and guardrails
- Smaller base images can lack libraries your app needs
- Approve each file change; do not let it run commands blindly
- Check licenses and support status of suggested images
Sources
Written by Agents Lookup. Credits and official pages for the tools this use case names:
- Docker docs: Gordon: docs.docker.com/ai/gordon