4. Setup via Agents: Codex & Claude

Using artificial intelligence to build the artificial environment. How to prompt coding models to generate your Sandbox.

If you are new to Docker, writing a docker-compose.yml file to link an Apache server, a PHP environment, and a MySQL database together can take hours of troubleshooting network bridges and volume mounts. But you don’t have to write it yourself. You can use AI to build your AI’s environment.

Highly capable coding models like Claude 3.5 Sonnet, GPT-4o, or local code-specific models (like DeepSeek Coder or CodeLlama) are exceptional at generating Docker configurations.

The Art of the DevOps Prompt

When asking an LLM to generate your testing sandbox, you must be extremely specific about the environment you want. Vague prompts lead to broken configurations.

🎯 The Perfect Setup Prompt

“I am building a sandbox environment for an autonomous AI agent. Write a docker-compose.yml file that sets up the following three isolated containers:
1. A PHP 8.2 container running Apache on port 8080.
2. A MySQL 8 database container.
3. A phpMyAdmin container on port 8081 connected to the database.

Crucial Requirements:
– Network them together on a custom bridge network called ‘agent_net’.
– The Apache document root MUST be mounted to a local directory called ‘./agent_workspace’ so my agent script on the host can write files directly into the web server.
– Provide the initial SQL script to create a dummy database called ‘agent_test’.”

Why this prompt works

  • Clear Architecture: It specifies exactly what services are needed and their exact versions.
  • Network Isolation: It explicitly asks for a bridge network, ensuring the containers can talk to each other without exposing unnecessary ports to your host machine.
  • The Volume Mount (Crucial): The instruction to mount ./agent_workspace is the most important part. Your agent orchestration script (running on your Mac/PC) needs a way to pass the files it generates into the Docker container. By using a shared volume, the agent can write a file to a regular folder on your desktop, and it instantly appears inside the isolated Apache web server.

Validating the Output

Never blindly run the docker-compose up command generated by an LLM without reading it first. Check the environment variables in the generated YAML file. Often, the LLM will generate default passwords (like root/password). Since this is a local, isolated testing environment, weak passwords are fine, but you need to know what they are so you can hardcode them into your agent’s database tool later.