Skip to content

doc: document how to use tesseract serve --network parameter#530

Open
zmheiko wants to merge 8 commits intomainfrom
heiko/document-network-flag
Open

doc: document how to use tesseract serve --network parameter#530
zmheiko wants to merge 8 commits intomainfrom
heiko/document-network-flag

Conversation

@zmheiko
Copy link
Copy Markdown
Contributor

@zmheiko zmheiko commented Mar 18, 2026

This addresses the lack of documentation around network usage and some of its pitfalls.

Relevant issue or PR

This acts as a stopgap for #410. Moving forward, more tooling around network usage is needed.

Description of changes

Add documentation

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.77%. Comparing base (eb4438f) to head (7a9e1e0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #530   +/-   ##
=======================================
  Coverage   66.77%   66.77%           
=======================================
  Files          32       32           
  Lines        4409     4409           
  Branches      730      730           
=======================================
  Hits         2944     2944           
  Misses       1226     1226           
  Partials      239      239           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


`--network=host` makes a container share the host's network stack, which can be a convenient alternative to creating an explicit Docker network. However, it does not work correctly on all platforms. On macOS and Windows, Docker Desktop runs the Docker daemon inside a lightweight VM. The "host" from the daemon's perspective is that VM, not your actual machine, so `--network=host` gives the container access to the VM's network rather than your host's. This means services running on your machine are not reachable via `localhost` from inside the container, and the pattern of calling Tesseracts by host address will not work as expected.

At the moment `--network=host` works as intended only on Linux, where the Docker daemon runs directly on the host. Alternatives to Docker Desktop that run the daemon more natively, such as [Colima](https://github.com/abiosoft/colima), may also support host networking correctly. For cross-platform workflows, prefer creating an explicit Docker network as shown above.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tried this? IIUC, Docker Desktop will also run containerized on Linux, so it really boils down to whether you use Docker Desktop or Engine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I confused Docker Desktop and Engine here. I have not tested it recently, but I experimented with it when Linus and I first encountered these failures. Back then I got it working on Linux. I never installed Docker Desktop on the Azure VM so it must have just been Engine.

So yeah, this is wrong and needs rephrasing. I'll double-check that the setup on Linux indeed works and change the paragraph accordingly.

@dionhaefner
Copy link
Copy Markdown
Contributor

Thanks @zmheiko ! Do you think we should pull the trigger and also create networks passed with --network if they don't exist, or is there another footgun to that I'm not seeing?

@zmheiko
Copy link
Copy Markdown
Contributor Author

zmheiko commented Mar 18, 2026

Thanks @zmheiko ! Do you think we should pull the trigger and also create networks passed with --network if they don't exist, or is there another footgun to that I'm not seeing?

The only drawback that I'm seeing is that the user might pass a wrong network name (e.g. XXY), misses the emitted "new network XXY created" message (that I assume we'd add), and then wonders why the new Tesseract cannot communicate with the existing ones in network XXX. So maybe an additional --create-network flag that needs to be passed on top of the --network=XXX args would be useful to make sure networks are created intentionally instead of by accident because of a typo. Does that make sense?

@dionhaefner dionhaefner changed the title doc: document network usage doc: document how to use tesseract serve --network parameter Mar 18, 2026
@zmheiko
Copy link
Copy Markdown
Contributor Author

zmheiko commented Mar 22, 2026

I updated the documentation and added a Ping-Tesseract that can be used to check if networking works. I tested it on Mac (with Colima, but this should behave the same way as Docker Desktop) and a Azure Linux VM (with Docker Engine). As expected, with --network=host pinging pasteurlabs.ai works but localhost fails on Mac. On Linux both succeed.

@zmheiko zmheiko requested a review from dionhaefner March 22, 2026 15:58
Comment on lines +124 to +142
To verify whether outbound network access works in your environment, you can use the [`examples/ping`](https://github.com/pasteurlabs/tesseract-core/tree/main/examples/ping) Tesseract, which fetches a URL and reports whether it was reachable:

```bash
$ tesseract build ./examples/ping
$ tesseract run ping:latest apply '{"inputs": {"url": "https://pasteurlabs.ai/"}}'
```

To specifically test if `--network=host` works, start a local webserver and check whether containers can reach it. First set up the server:

```bash
$ python3 -m http.server 9999
```

Then, while the server is running, target the ping Tesseract at it:

```bash
$ tesseract run --network=host ping:latest apply '{"inputs": {"url": "http://localhost:9999"}}'
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice touch but I'm not sure if it's worth it to add yet another example tested on every commit just for this use case. For now the section above it seems appropriate: Here is the recommended way to do it; if you feel like you must use host beware because there be dragons. So unless you have strong feelings regarding the ping Tesseract I suggest we drop it for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong feelings. I used it for testing and thought I might as well add it.

Comment on lines +105 to +110
You can create a Docker network and attach Tesseracts to it using the `--network` flag.

```bash
$ docker network create my_network
$ tesseract serve "my-tesseract:latest" --network my_network --network-alias my-tesseract --port 8000
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we patch in auto-generation of networks right away? Otherwise we'll end up refactoring this part of the docs again once we do.

@zmheiko
Copy link
Copy Markdown
Contributor Author

zmheiko commented Mar 28, 2026

#544 tackles automatic network creation. Let's revisit the doc changes after, as you suggested @dionhaefner.

dionhaefner added a commit that referenced this pull request Apr 1, 2026
…it does not exist (#544)

#### Relevant issue or PR

#530 documents how to use the `--network` option and needs updating once
this PR is merged.

#### Description of changes

When `--network <name>` is passed to `tesseract serve` or `tesseract
run` and no network with that name exists, we now automatically create
it instead of failing with a Docker error.


#### Testing done

Tested that multi-Tesseract hello world example works without explicit
network creation.

---------

Co-authored-by: Dion Häfner <dion.haefner@simulation.science>
@dionhaefner
Copy link
Copy Markdown
Contributor

Done, @zmheiko do your thang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants