The following example creates an agent that can manage Docker resources:
cookbook/91_tools/docker_tools.py
import sysfrom agno.agent import Agenttry: from agno.tools.docker import DockerTools docker_tools = DockerTools() docker_agent = Agent( name="Docker Agent", instructions=[ "You are a comprehensive Docker management assistant.", "You can manage containers, images, volumes, and networks.", ], tools=[docker_tools], markdown=True, ) docker_agent.print_response("List all running Docker containers", stream=True) docker_agent.print_response("Pull the latest nginx image", stream=True) docker_agent.print_response( "Run an nginx container named 'web-server' on port 8080", stream=True )except ValueError as e: print(f"\n[ERROR] Docker Tool Error: {e}") print("\nTroubleshooting steps:") if sys.platform == "darwin": # macOS print("1. Ensure Docker Desktop is running") print("2. Check Docker Desktop settings") print("3. Try running 'docker ps' in terminal to verify access") elif sys.platform == "linux": print("1. Check if Docker service is running:") print(" systemctl status docker") print("2. Make sure your user has permissions to access Docker:") print(" sudo usermod -aG docker $USER") elif sys.platform == "win32": print("1. Ensure Docker Desktop is running") print("2. Check Docker Desktop settings")
DockerTools registers all functions by default, including remove_container, remove_image, remove_volume, remove_network, and exec_in_container, which runs an arbitrary command inside a container. There’s no allowlist or confirmation gate. Use include_tools/exclude_tools to scope access, and keep human supervision for untrusted prompts.