Tutorial

Setting Up the Safety Net: Antigravity + Dev Containers

Setting up a safe sandbox for AI agents to work in.

Tom HaskellTom Haskell
AIDev ContainersDevOpsAntigravityDocker

In my last post, I mentioned that using devcontainers was my "no-brainer" move for vibe-coding. If you’re letting an AI agent like Gemini Pro or Claude Code drive your terminal, you want a sandbox that keeps your host machine safe from any "creative" rm -rf commands or stray dependencies. It also has the usual advantages of pre-configured dev environments when others join the project - with or without AI assistance.

Setting this up in Antigravity is slightly different from your standard VS Code workflow. Here’s how I got mine running.

1. The Custom Dockerfile (Don't Go "Slim")

Antigravity’s agents need specific tools to function—things like tar, bash, git, and curl. While many pre-built images are "slim" to save space, I found it's better to use a full Ubuntu base so the agent has everything it needs to install its own server binaries.

Key Tip: You must explicitly set the HOME environment variable to /root (or your user's home) and ensure it's writable, otherwise the Antigravity server installation might fail silently.

Also remember to update your WORKDIR to wherever your project lives.

# .devcontainer/Dockerfile

# Use a robust base image
FROM mcr.microsoft.com/devcontainers/base:ubuntu

# If you're using Node: install Node.js 22 LTS via NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
    && apt-get install -y nodejs \
    && npm install -g npm@latest

# Install the essentials the Antigravity agent needs to work
RUN apt-get update && apt-get install -y \
    curl \
    git \
    tar \
    coreutils \
    && apt-get clean

# Ensure the agent has a writable home directory
ENV HOME=/root
WORKDIR /workspaces/<my-project-dir>

2. Configuring devcontainer.json

This is the "bridge" that tells Antigravity how to build and connect to your sandbox. Since I was building a Nuxt site, I needed to make sure my ports were open so I could actually see the site the agent was building.

This is also where I set the agent to auto-accept terminal commands, and install a few standard VSCode extensions that I needed (obviously add your own favourites)

{
  "name": "Vibe-Coding Sandbox",
  "build": {
    "dockerfile": "Dockerfile"
  },
  "remoteUser": "root",
  "features": {
    "ghcr.io/devcontainers/features/git:1": {},
    "ghcr.io/devcontainers/features/common-utils:1": {},
    "ghcr.io/devcontainers/features/node:1": {
      "version": "22"
    }
  },
  "forwardPorts": [3000],
  "customizations": {
    "antigravity": {
      "settings": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "esbenp.prettier-vscode",
        "terminal.integrated.defaultProfile.linux": "bash",
        "antigravity.agent.autoAccept": true
      },
      "extensions": ["Vue.volar", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "bradlc.vscode-tailwindcss"]
    }
  }
}

The Result

With this setup, I could give the agent a high-level goal—like "Refactor the navigation to be mobile-responsive"—and it would generate a plan, run the npm installs, and verify the changes in the background while I grabbed a coffee.

Latest Posts

View All
Opinion

Is AI making me obsolete?

There’s been a lot of talk about AI making developers obsolete. Is it all hype, or should I be concerned?

Read
Read Post
Tutorial

Setting Up the Safety Net: Antigravity + Dev Containers

Setting up a safe sandbox for AI agents to work in.

Read
Read Post
Opinion

Vibe-coding My Website

I finally stopped procrastinating and built my website, giving agentic AI a go in the process.

Read
Read Post