Giving an AI agent unrestricted access to your entire computer is probably not a great idea.
Especially when that agent can:
- Run terminal commands
- Install packages
- Create and modify files
- Access external services
- Work autonomously through multi-step tasks
Those capabilities are exactly what make Hermes Agent powerful.
But they also raise an important question:
Where should all of those actions actually run?
Instead of running Hermes Agent directly on my host machine, I decided to run it inside a Docker container and explicitly control what the agent can access.
The goal isnβt to make Hermes magically βsecureβ by putting it inside Docker.
The goal is much simpler:
Give the agent access to what it needs, not your entire computer.
In this tutorial, Iβll walk through the complete setup.
Weβll configure:
- Hermes Agent inside Docker
- Persistent storage for memory, sessions, and configuration
- A limited filesystem boundary
- Hermes Gateway
- Hermes Dashboard
- Dashboard authentication
- Hermes Desktop connected to the container
- Some important security considerations when containerizing autonomous AI agents
π₯ Prefer watching instead?
I walk through the complete setup step-by-step in the video:
Watch the full Hermes Agent Docker tutorial on YouTube β
π€ Why Run Hermes Agent Inside Docker?
Hermes isnβt just a chatbot.
It can interact with your environment and perform actions on your behalf.
For example, depending on the tools you enable, Hermes can work with files, execute terminal commands, install dependencies, use external services, and autonomously work through tasks.
Thatβs incredibly useful.
But if the agent runs directly on your main machine, you need to think carefully about what files, credentials, and system resources it can reach.
Thatβs where Docker becomes useful.
Instead of letting Hermes operate directly across my host environment, I can put it inside a container and explicitly decide what crosses that boundary.
The architecture weβll build looks roughly like this:
βββββββββββββββββββββ HOST MACHINE βββββββββββββββββββββ
β β
β Docker β
β β
β ~/.hermes-docker ββββββββββββββββ β
β β β
β ββββββββββββββββΌβββββββββββββββ β
β β Docker Container β β
β β β β
β β Hermes Agent β β
β β β β
β β /opt/data β β
β β Gateway β β
β β Dashboard β β
β βββββββββββββββββββββββββββββββ β
β β
β Personal files / SSH keys / other directories β
β NOT mounted into container β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Hermes gets a dedicated environment and a directory for its persistent data.
The rest of the machine stays outside that boundary unless I explicitly expose something.
π³ Step 1: Install Docker
On macOS or Windows, install Docker Desktop and make sure the Docker engine is running.
On Linux, you can install Docker Engine using the instructions for your distribution.
You can verify Docker is available with:
docker --version
Once Docker is working, we can create an isolated environment for Hermes.
π Step 2: Create a Dedicated Directory for Hermes
First, create a directory specifically for the Dockerized Hermes instance:
mkdir -p ~/.hermes-docker
This directory is important for two reasons.
1. Persistence
Docker containers are disposable.
If we remove and recreate the Hermes container, we donβt want to lose things like:
- Configuration
- Sessions
- Memory
- Skills
- Profiles
- Logs
- Other persistent agent data
Weβll store those outside the container in ~/.hermes-docker.
2. It becomes part of our trust boundary
Anything inside this directory is intentionally available to Hermes.
Instead of mounting my entire home directory, Iβm giving the agent one dedicated location.
That distinction matters.
βοΈ Step 3: Run the Hermes Setup Inside Docker
Now we can start the official Hermes Agent image and launch the setup process:
docker run --rm -it \
-v ~/.hermes-docker:/opt/data \
nousresearch/hermes-agent setup
The most important part here is:
-v ~/.hermes-docker:/opt/data
The -v option creates a bind mount between a directory on the host and a directory inside the container.
Think of it like this:
HOST CONTAINER
~/.hermes-docker ββββββββΆ /opt/data
The left side:
~/.hermes-docker
is the directory we just created on the host.
The right side:
/opt/data
is where that directory appears inside the Docker container.
So when Hermes saves configuration, sessions, memory, skills, or other persistent data under /opt/data, those files are actually stored in ~/.hermes-docker on the host.
That means we can destroy and recreate the container without losing the Hermes environment.
More importantly, weβre sharing one dedicated directory instead of the entire host filesystem.
π§ Step 4: Configure Hermes Agent
The first run downloads the required Docker image and launches the Hermes setup wizard.
From there, follow the normal Hermes configuration process.
In my setup, I:
- Use the quick setup
- Authenticate with Nous Portal
- Select a model
- Keep the terminal backend local
- Skip messaging platform configuration for now
Once setup finishes, the configuration is stored in our persistent directory.
That means future containers using the same mount can reuse it.
π Step 5: Start the Hermes Gateway and Dashboard
Now we can start Hermes as a background container:
docker run -d \
--name hermes-docker \
--restart unless-stopped \
-v ~/.hermes-docker:/opt/data \
-p 18642:8642 \
-p 19119:9119 \
-e HERMES_DASHBOARD=1 \
nousresearch/hermes-agent gateway run
There are a few important things happening here.
Run in the background
-d
starts the container in detached mode.
Give the container a name
--name hermes-docker
makes it easier to manage later:
docker logs hermes-docker
docker stop hermes-docker
docker start hermes-docker
Keep the persistent directory
Weβre mounting the same directory again:
-v ~/.hermes-docker:/opt/data
So Hermes sees the configuration we created during setup.
Enable the dashboard
-e HERMES_DASHBOARD=1
enables the Hermes Dashboard.
π Understanding the Port Mapping
Youβll notice Iβm using:
-p 18642:8642
-p 19119:9119
Docker port mappings follow this pattern:
HOST_PORT:CONTAINER_PORT
So:
18642 β 8642
19119 β 9119
The ports on the right are the ones Hermes uses inside the container.
The ports on the left are the ones exposed on my Mac.
Iβm deliberately using different host ports because I already have another Hermes instance running locally and donβt want the ports to clash.
If youβre running only the Docker instance, you can use the default ports 8642 and 9119 instead of 18642 and 19119.
β Step 6: Verify the Container Is Running
Run:
docker ps
You should see the hermes-docker container running.
If something isnβt working, one of the first places to look is the container logs:
docker logs hermes-docker
This becomes particularly useful when configuring the dashboard.
π Step 7: Configure Dashboard Authentication
When I initially opened the dashboard, it didnβt start correctly.
Instead of hiding that part from the tutorial, I kept it in because itβs a useful troubleshooting example.
Checking:
docker logs hermes-docker
showed that the dashboard needed an authentication provider.
Hermes provides authentication options for securing dashboard access.
I configured mine using Nous Portal authentication.
Once authentication was configured, the dashboard started successfully.
With my port mapping, I can access it at:
localhost:19119
And now the Hermes Dashboard is running while Hermes itself remains inside the container.
π¬ Step 8: Chat With Hermes Inside the Container
You can also enter the running container directly:
docker exec -it hermes-docker bash
Then start Hermes:
hermes
At this point youβre interacting with Hermes from a terminal inside the Docker container, rather than running Hermes directly on the host.
Thatβs useful for testing.
But I donβt necessarily want to enter the container every time I want to use the agent.
Thereβs a better option.
π₯οΈ Step 9: Connect Hermes Desktop to the Docker Instance
Hermes Desktop can connect to the Gateway running inside our container.
Open Hermes Desktop and navigate to:
Settings β Gateway β Remote Gateway
Then configure it to use the Gateway exposed by your Docker container.
In my setup, thatβs my url:
http://localhost:19119
After authenticating, save the configuration and reconnect.
Now Hermes Desktop communicates with the Dockerized Hermes instance.
So from the userβs perspective, I still get the convenient desktop interface.
But the agent itself is operating inside the container.
π‘οΈ What Does Docker Actually Protect?
This is probably the most important part of the tutorial.
Running an AI agent inside Docker does not automatically make it safe.
Docker gives us a useful isolation boundary, but that boundary depends heavily on how the container is configured.
For example, imagine doing this:
Host machine
β
βΌ
Entire home directory
β
βΌ
Docker container
β
βΌ
Hermes Agent
Youβve technically containerized Hermes.
But youβve also exposed a huge portion of your machine to it.
Thatβs not the setup I want.
Instead:
Host machine
β
βββ Personal files β
βββ SSH keys β
βββ Other projects β
βββ Docker socket β
β
βββ ~/.hermes-docker β
β
βΌ
Hermes Container
The container should get access only to the resources required for the task.
π« 1. Donβt Mount Your Entire Home Directory
If you mount your complete home directory into the container, Hermes could potentially access whatever the containerβs permissions allow within that mount.
That might include personal files, source code, configuration files, credentials, or other sensitive data.
Thatβs why Iβm using:
~/.hermes-docker
as a dedicated location instead.
If Hermes doesnβt need something, donβt expose it.
π 2. Be Careful With Credentials
The same principle applies to API keys and tokens.
Only provide the credentials Hermes actually needs.
Avoid unnecessarily exposing things such as:
~/.ssh
or unrelated cloud credentials and secrets.
Containerization doesnβt help much if you put every sensitive credential inside the container anyway.
β οΈ 3. Donβt Expose the Docker Socket Without a Very Good Reason
Another thing Iβm deliberately not mounting is:
/var/run/docker.sock
Giving a container access to the host Docker daemon can dramatically expand what that container is capable of doing.
For an autonomous agent, thatβs an especially important boundary to think about.
If Hermes doesnβt need to control Docker on the host, donβt give it that capability.
π§© 4. Docker Doesnβt Solve Prompt Injection
Thereβs another important limitation.
An AI agent can still encounter malicious or adversarial content.
For example, content from a webpage, repository, document, or other external source could attempt to manipulate the agent into performing unintended actions.
Putting the agent inside Docker doesnβt eliminate that problem.
The difference is what happens after the agent attempts the action.
If Hermes only has access to:
/opt/data
then weβve limited the environment available to it.
If weβve mounted our entire computer, exposed sensitive credentials, and given it access to the Docker daemon, the potential impact is very different.
Thatβs why I think containerization is better understood as blast-radius reduction, not a magic AI security solution.
π― The Principle: Least Privilege for AI Agents
As AI agents become increasingly capable, I think one traditional security principle becomes even more important:
Least privilege.
An agent should receive the minimum access required to complete its task.
Not:
Agent
β
βββ Everything on my computer
But:
Agent
β
βββ Required files
βββ Required credentials
βββ Required network services
βββ Required tools
Nothing more.
This becomes increasingly important as agents gain longer-running autonomy, terminal access, browser access, external integrations, scheduled execution, and the ability to coordinate multiple tools.
Docker vs VM for AI Agents
Docker is not the only way to isolate an autonomous agent.
You could also use:
- A virtual machine
- A dedicated VPS
- A sandboxed execution environment
- A separate physical machine
- More restrictive container runtimes
A VM generally provides a stronger isolation boundary than a standard application container because it virtualizes a larger portion of the environment.
Docker, however, is lightweight and convenient for local development.
For my Hermes setup, it gives me a useful middle ground:
Direct Host Execution
β
Docker Container
β
Virtual Machine / Dedicated Environment
The appropriate boundary ultimately depends on what capabilities youβre giving the agent and what resources it can access.
Final Architecture
After everything is configured, my setup looks roughly like this:
βββββββββββββββββββββββββββββββ
β Host Machine β
β β
β Hermes Desktop β
ββββββββββββββββ¬βββββββββββββββ
β
Remote Gateway
β
βΌ
βββββββββββββββββββββββββββββββββββ
β Docker Container β
β β
β Hermes Gateway β
β Hermes Dashboard β
β Hermes Agent β
β β
β /opt/data β
βββββββββββββββββ¬ββββββββββββββββββ
β
Bind Mount
β
βΌ
~/.hermes-docker
β
βββββββββββββββββ΄βββββββββββββββ
β Config β’ Memory β’ Sessions β
β Skills β’ Profiles β’ Logs β
ββββββββββββββββββββββββββββββββ
Rest of host filesystem β NOT MOUNTED
SSH keys β NOT EXPOSED
Docker socket β NOT EXPOSED
Hermes still has the environment it needs to work.
But weβre being much more deliberate about what crosses the boundary.
Final Thoughts
Autonomous AI agents are becoming capable of doing much more than generating text.
Theyβre increasingly able to:
β‘ Execute commands
ποΈ Manipulate files
π Interact with external systems
π§° Use specialized tools
π Run multi-step workflows autonomously
Thatβs exciting.
But the more capable the agent becomes, the more important its execution environment becomes.
Running Hermes Agent inside Docker doesnβt solve every security problem.
It does, however, give us a practical way to control what the agent can access and reduce the potential blast radius when something unexpected happens.
The rule I follow is simple:
Only give an AI agent access to what it actually needs.
Everything else should stay outside the boundary.
Top comments (1)
If youβre already running Hermes Agent or another autonomous AI agent, Iβm curious how youβre isolating it:
Docker, VM, VPS, sandbox or directly on your host machine?
Drop your setup in the comments. π