- OpenHands acts as an autonomous engineering team capable of programming, testing, and browsing the web in isolated environments.
- The Docker-based architecture ensures that AI actions do not compromise the security of the host server.
- It supports a wide range of language models, from commercial options like GPT-4o and Claude to local implementations using Ollama.
Imagine having a teammate who never sleeps, who can devour library documentation in seconds, and who can autonomously write code without you having to supervise every line. That's precisely what OpenHands is: an open-source platform that has revolutionized how we understand software engineering, allowing AI agents to manage complex tasks from planning to test execution.
The most powerful aspect of this system is that it doesn't just stop at a simple chat that suggests code snippets; it operates in a real-world environment . Thanks to its integration with containers, the agent can read files, run commands in the terminal, and even browse the internet to troubleshoot bugs, all while keeping your infrastructure safe in a sandbox. Essentially, it's the transition from a text-based assistant to a complete software operator that you can self-host on your own server.
Prerequisites and environment preparation

Before we begin the installation, we need to ensure the VPS has a solid foundation. Essentially, you need to have Docker Engine or Docker Desktop installed and functioning correctly. If you're in a Linux environment (such as Ubuntu 22.04), make sure the Docker daemon is running. For those using Windows via WSL 2, it's vital that integration with your Linux distribution is enabled in the Docker Desktop settings.
Regarding hardware, while OpenHands is efficient, don't skimp on resources. A modern processor and at least 4GB of RAM are recommended , but if you plan to run local language models or very demanding tasks, increasing the RAM and adding GPU power will save you a lot of headaches and speed up the agent's response.
Step-by-step installation using Docker

The most robust and clean way to deploy OpenHands is through a container. First, it's recommended to download the runtime image to prevent startup from hanging. You can use the 0.34-nikolaik tag , which is one of the most stable for sandboxing.
To launch the application, you must run a Docker command that configures the necessary environment variables. It's crucial to map the Docker socket `/var/run/ docker.sock` so that OpenHands can start other isolated containers where the agent will work. You should also create a persistent volume, such as `~/.openhands-state` , so that your conversations and keys don't disappear when you restart the container. The standard port for accessing the web interface is usually 3000 , although some modern versions of Agent Canvas use port 8000.
Brain Configuration: Connecting with LLMs

Once you access the web interface, the first thing you'll see is the settings panel. OpenHands is model-agnostic, meaning you can choose the reasoning backend that best suits your needs. If you're looking for maximum power, options like OpenAI's GPT-4o or Anthropic's Claude 3.5 Sonnet are the safest bets.
For those who prefer to maintain complete sovereignty over their data, the option is to use local models via Ollama . Here's an important tip: since OpenHands runs within Docker, you can't use "localhost" to connect to Ollama; instead, you must use the address http://host.docker.internal:11434 . In this case, models like Qwen 2.5 Coder have proven surprisingly capable for programming tasks.
Agent workflows and capabilities

Once the system is up and running, you can start giving it commands. The workflow is simple: the agent receives the instruction, designs a strategic plan , executes the actions in the sandbox, and verifies the result. You can ask it to do anything from trivial things, like creating a bash script to say hello, to building a complete React application from scratch, managing state with localStorage.
If you already have a project underway, OpenHands can come to the rescue to refactor old code or add new routes to an Express.js API. Ideally, you should be very specific: instead of telling it "fix the login," it's much better to specify the exact file path and the erroneous behavior you've detected. This reduces the error rate and prevents the AI from wasting time searching for irrelevant files.
Sandbox security and management
Security is the cornerstone of OpenHands. Each session runs in an isolated container , preventing a poorly executed AI command from accidentally deleting the root directory of your VPS. The Docker runtime acts as a barrier. However, if you need the agent to create its own containers (for example, to test a Dockerfile it has written), you must start OpenHands with the `--privileged` flag , although this weakens the isolation and should be done with caution.
To keep the system up to date, simply stop the current container and launch a new one with the updated image tag . It's recommended to synchronize the main application version with the runtime version to avoid communication incompatibilities between the kernel and the sandbox.
Tips for Best Results
To prevent the agent from getting lost, the key lies in detailed prompting . Break down monumental tasks into small, iterative steps. Instead of requesting an entire website, first request the folder structure, then the basic components, and finally the business logic. Furthermore, integrating version control is a very good practice , requiring the agent to make commits with clear messages each time it completes a feature.
Deploying OpenHands on a VPS transforms code management into an assisted process where the human becomes an architect and reviewer rather than a keyboard warrior. By combining the power of Docker with the flexibility of modern LLMs, we have a tool capable of automating the software lifecycle, maintaining security through isolation and flexibility thanks to support from multiple AI vendors.
FAQ
How do I connect OpenHands with Ollama if I'm using Docker?
The base URL must be set to http://host.docker.internal:11434 in the interface settings, since localhost inside the container does not point to the VPS host.
Is it safe to let OpenHands run commands on my server?
The system uses Docker containers as a sandbox to isolate the agent's actions, preventing commands from directly affecting the host's operating system.
What should I do if I receive a permissions error in Linux when starting the container?
It is necessary to ensure that the user with UID 10001 inside the container has read and write permissions on the volume or directory mounted on the host.
Can I use OpenHands without paying a monthly subscription?
Yes, because it's an open-source platform that you can self-host, paying only for the API usage of the LLM you choose or using free local models.
What is the purpose of the --privileged flag when running the container?
It allows the AI agent to start and manage other Docker containers within the sandbox, which is necessary for Dockerfile deployment or testing tasks.
What is the difference between Agent Canvas and the OpenHands CLI?
Agent Canvas is the modern interface and current control center, while the CLI is mainly maintained for headless mode executions and CI/CD flows.