Can You Self-Host Cursor, Codex, Claude Code, and Other Coding Agents?

·5 min read
aiai-agentsdockerself-hosteddeployment

Running a coding agent on your server is possible, but an official Docker image does not necessarily contain a complete cloud coding service. Cursor has self-hosted workers, Codex has a local CLI and a self-hosted executor, and Claude Code can run in development containers. OpenCode is a closer candidate for a standalone browser-accessible coding agent from a published image.

This assessment checks official documentation on October 28, 2026 against the one-click deploy link requirement: one published image, with a command, environment variables, ports, and persistent volumes. These are documentation findings, not live-tested deployments.

Compare the deployment models

Product or mode What you can run on your infrastructure Fit for one official-image deploy link
Cursor-managed Cloud Agents Cursor operates the agent environments Not a self-hosted application image
Cursor Self-Hosted Machines A worker executing tools while Cursor operates the agent loop Conditional worker-hosting candidate; needs CLI installation, registration, credentials, and a prepared workspace
Codex CLI The coding agent working in your repository Containerizable, but requires installation, authentication, project tools, and an interaction or job mechanism
OpenAI self-hosted executor A codex exec-server process connected to an Agents API session Conditional executor-hosting candidate; not the complete cloud agent application
Claude Code CLI/SDK execution in an environment you prepare Official container installation guidance, but not established here as a ready-to-run official web-app image
OpenCode A coding agent with a web interface and HTTP server Strongest documented single-image candidate in this comparison; verify the image command and project tooling
Gemini CLI Terminal or automated coding tasks, with documented container sandboxing Official image documented for sandbox execution; not a ready-made web application

Cursor: distinguish managed cloud from self-hosted tool execution

Cursor's Cloud Agents normally work in isolated development VMs. Providing a Dockerfile customizes that environment; it does not export the Cursor cloud service for deployment elsewhere.

However, Self-Hosted Machines is a supported option. Cursor runs inference, planning, and the agent loop; your worker edits files and runs terminal commands. Workers can run on persistent hosts or in containers and connect outbound, so no public inbound port is required.

Personal machines and enterprise team pools have different registration and account requirements. A deployment also needs repository access, installed tools, persistent workspace policy, and worker credentials. The documented reference architectures leave the worker image and infrastructure to the operator. Assessment: possible worker hosting, but the checked documentation does not establish a universal prebuilt Cursor image suitable for a complete one-click recipe.

Codex: CLI, environment image, and executor are different pieces

The Codex CLI runs against your repository and supports interactive work and codex exec automation. It can be installed in a container, but that alone does not supply a browser frontend, repository checkout, project dependencies, or a queue for tasks.

The cloud-environment documentation describes codex-universal as an environment image with common languages and tools. Treat it as development infrastructure, not evidence that pulling it starts the complete Codex cloud service.

OpenAI also documents self-hosted sandboxes. You run codex exec-server in your environment while OpenAI operates the agent harness. The executor connects outbound and needs the environment ID, remote URL, and a restricted environment key associated with an API session. An application creates sessions and submits work separately.

Assessment: useful paths for hosting a CLI worker or executor, with additional setup. Neither is a complete image-only clone of the hosted Codex experience.

Claude Code: official container support is an installation workflow

Anthropic documents development containers, including the official feature ghcr.io/anthropics/devcontainer-features/claude-code:1.0. A Dev Container Feature is an installation component applied when building a development environment, not a standalone image you can paste into the Existing Image form.

Claude Code in the cloud and Remote Control are separate options. Remote Control keeps execution on your machine and connects it to Claude's browser/mobile interface. It requires eligible subscription authentication; API-key authentication is not supported for that feature.

Assessment: a containerized Claude Code runner is feasible with a prepared environment, but the reviewed docs do not establish a turnkey official self-hosted web image. Remote Control could be useful for a persistent hosted runner after checking account eligibility, login persistence, and container compatibility.

OpenCode: the closest match to the original image-only requirement

The official installation instructions publish ghcr.io/anomalyco/opencode. OpenCode also documents a web interface and HTTP server.

For a web deployment, the intended application invocation is:

opencode web --hostname 0.0.0.0 --port 4096

Set OPENCODE_SERVER_PASSWORD privately before exposing it. The username defaults to opencode, with OPENCODE_SERVER_USERNAME available to override it. Map container port 4096 through HTTPS.

Before turning that into a deploy link, inspect the exact image tag's entrypoint. If it already runs opencode, the panel command should contain only web --hostname 0.0.0.0 --port 4096; the platform preserves ENTRYPOINT.

Persist the repository workspace and the application's data and configuration directories. The storage reference places Linux session data and credentials under ~/.local/share/opencode, and global configuration under ~/.config/opencode. Resolve these against the image's actual user and home directory instead of assuming /root. Supply provider credentials separately from the server password.

Assessment: a strong candidate for a dedicated deployment recipe. The remaining validation is image-specific: startup arguments, writable paths, authentication, browser behavior behind HTTPS, and availability of the tools needed to build and test your project. The current docs distinguish OpenCode 1 and 2; pin the selected generation and validate it rather than mixing instructions across versions.

Gemini CLI: an official sandbox image is not a hosted UI

Gemini CLI's sandboxing documentation identifies ghcr.io/google/gemini-cli:latest as its default Docker/Podman sandbox image. The normal sandbox workflow expects a Docker or Podman runtime and mounts the project into it. Its installation guide covers the CLI itself.

Assessment: candidate for terminal or automated tasks after checking the image's contents and invocation. Do not translate the nested-container sandbox workflow into a deploy link that assumes access to the platform host's Docker daemon. A public browser UI would be an additional component.

What a coding-agent deployment needs beyond chat

A useful runner needs a repository checkout, project runtimes, dependency installation, Git identity and scoped repository credentials, persistent state, and a way to submit and observe tasks. Some workloads also need browser binaries, operating-system packages, or a sandbox unavailable in a basic application container.

For outbound workers, leave public ports unbound. For an HTTP interface, configure authentication before startup and expose only the required HTTPS port. Preserve work across container replacement and test a real edit/build/test task; a successful model response proves much less than a working coding environment.

For general chat and document assistants with more directly specified image recipes, return to the assistant comparison. Coding-agent execution, model access, and hosting each have their own account and billing requirements.