OpenCode in Docker: what the container reaches on the network
Introduction
This article is part of a larger manual,
OpenCode in Docker on Ubuntu 24.04.
The manual shows how to run OpenCode with
the --auto option inside a
Docker container.
With --auto the agent does not ask you before
each command, so the container limits what it can reach: the agent works
only in one git worktree, a separate copy of the
project.
The container sees only the files that are mounted into it. The network
is different.
This article shows what the container can still reach on the network,
and how to close the local site.
What the container reaches
The container goes out through the host, and it reaches the host itself at 172.17.0.1, the gateway of the default Docker network. Checked with wget from the container:
| Target | Host listens on | From the container |
|---|---|---|
| local site, 172.17.0.1:8080 | 0.0.0.0 | reachable |
| test reports, 172.17.0.1:5050 | 0.0.0.0 | reachable |
| dashboard, 172.17.0.1:8765 | 127.0.0.1 | refused |
| 127.0.0.1:8080 | — | refused: the container's own loopback |
| the internet | — | reachable, the model needs it |
Close the local site
The local site serves the main checkout, ignored files included, so what
the worktree of step 2 (a
worktree for the agent) kept out is one request away.
Publish its port on 127.0.0.1: the browser on
the host keeps working, and the container gets
Connection refused:
vi container/docker-compose.yml
php-apache: ports: - "127.0.0.1:8080:80"
Every other port
Every other port gets the same prefix. Each line of this command with 0.0.0.0 or [::] is a service the container can reach:
ss -ltn
The internet stays open. Limiting it to the model's host takes a proxy in front of the container.
Article author: Klavdiya Kondakova