I’m very grateful for @error-404 ‘s script and the other suggestions here . I was able to get my agent setup mostly working based on that.
For anyone else trying to get Docker running with the agent, here’s the process that worked for me.
Step 1: Install Docker
First, I install Docker using the convenience script and add my user to the `docker` group:
curl -fsSL \[https://get.docker.com\](https://get.docker.com) -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
rm get-docker.sh
Step 2: Configure the Docker Daemon
This was the most critical part. Docker needs a specific daemon configuration to work inside the agent environment.
-
Create .cursor/daemon.json
I created a daemon.json file in my .cursor directory with the following content:
{
"iptables": false,
"bridge": null
}
-
install
I wrote a simple install script to copy this config to the right place and start the Docker service.
#!/bin.bash
sudo cp .cursor/daemon.json /etc/docker/daemon.json
sudo service docker start
(Inside this script, I can now run sudo docker ... commands successfully. newgrp was unreliable here.)
-
Update environment.json
Finally, I pointed the agent’s install step to this script:
{
...
"snapshot": "redacted",
"install": ".cursor/install.sh"
...
}
Writing the config to /etc/docker/daemon.json was the key. After this, once I’m on the background agent, I just need to run newgrp docker and things work mostly fine.
Important: Network Configuration
I found that all Docker RUN commands needing network access (like `apt install`, `pip install`, etc.) during a build require the host’s network.
-
docker build: Must use docker build --network=host ...
-
docker run/exec: Must use docker run --network=host ...
-
compose.yaml: Use network_mode: host under the service’s key, and network: host under the build key
Remaining Issues
I’m still running into a couple of problems:
- The agent snapshot doesn’t seem to update after the
install step runs.
- Terminals configured in
.cursor/environment.json don’t appear to start (tmux ls shows nothing)
- Sometimes docker is already running when the install script runs, so
sudo service docker start appears to fail. sudo service docker start || true sometimes works. sudo service docker stop/restart fail as they hang indefinitely.
Despite these, I have an agent that works much more closely to my local dev setup now. Hopefully this helps someone out, and that the Cursor team will keep iterating and improving this