Docker AGENTS.md
Containers feel local and then are not. This file tells the agent it may build and run the compose file on the laptop, and that pushing an image, deleting a volume, or pruning the disk waits for a person.
Point at the Dockerfile and the compose file the repository actually uses so the agent does not invent a second stack.
What to tell the agent
Do
- Name the compose file and the services a task is allowed to restart.
- Say which env file compose reads, without pasting secrets into AGENTS.md.
- Pin base images the way the Dockerfile already pins them.
- Ask the agent to leave registry credentials to the existing docker login.
Leave alone
- Using the latest tag for a base image the Dockerfile had pinned.
- Running privileged containers to make a build succeed.
- Pruning images and volumes as a cleanup step.
AGENTS.md to copy
Save this as AGENTS.md at the root of the repository, or next to the package it covers. Replace the commands with the ones in this repo. See which agents read the file.
# Docker ## Local - Build and run the compose file that is already in the repo. - Bind to localhost. Do not publish a database port on 0.0.0.0 for a test. - Read logs with docker compose logs when a service fails to start. Quote the first error. ## Images - A Dockerfile change should still build with the documented command. - Do not push to a registry, retag a release, or change a production base image unless the task is that release. ## Destructive commands - Ask before docker volume rm, docker system prune, docker compose down -v, or deleting a bind-mounted directory. - Do not remove a volume to "fix" a migration. Fix the migration. ## Checks - docker compose config should parse. - The documented build command should succeed. - Say which service you started and which URL you would open.
Checks named in the file
Confirm each command exists here before you rely on it. Delete the ones this repository does not use.
- Validate the compose file.
docker compose config - Build the local images.
docker compose build - Follow one service.
docker compose logs --tail=50 app
Questions
What is the Docker AGENTS.md for?
It lets an agent build and run the local compose file, and it keeps image pushes and volume deletes behind a person.
Which Docker commands can an agent run on its own?
Parse the compose file, build the images the repo defines, start the local stack, and read logs. Pushing an image and deleting volumes are release and data decisions.
What should AGENTS.md say about a failed container?
Read the service log and quote the first error. Removing the volume and starting over throws away the local database the last migration was checked against.