Skip to content

Bug: NatsContainer does not seem to work with JetStream #934

@jackburridge

Description

@jackburridge

Describe the bug

NatsContainer does not seem to work with JetStream

To Reproduce

Run the example_basic.py in the nats module.

You will first have to update the file as it doesn't run correctly, line 20 should be:

port = nats_container.get_exposed_port(nats_container.client_port)

It then fails on:

stream = await js.add_stream(name="test-stream", subjects=["test.>"])

With the error

python example_basic.py 
Connected to NATS
Traceback (most recent call last):
  File "/home/jackburridge/Dev/nats/.venv/lib/python3.10/site-packages/nats/js/manager.py", line 477, in _api_request
    msg = await self._nc.request(req_subject, req, timeout=timeout)
  File "/home/jackburridge/Dev/nats/.venv/lib/python3.10/site-packages/nats/aio/client.py", line 1068, in request
    raise errors.NoRespondersError
nats.errors.NoRespondersError: nats: no responders available for request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jackburridge/Dev/nats/example_basic.py", line 152, in <module>
    asyncio.run(basic_example())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/jackburridge/Dev/nats/example_basic.py", line 31, in basic_example
    stream = await js.add_stream(name="test-stream", subjects=["test.>"])
  File "/home/jackburridge/Dev/nats/.venv/lib/python3.10/site-packages/nats/js/manager.py", line 118, in add_stream
    resp = await self._api_request(
  File "/home/jackburridge/Dev/nats/.venv/lib/python3.10/site-packages/nats/js/manager.py", line 480, in _api_request
    raise ServiceUnavailableError
nats.js.errors.ServiceUnavailableError: nats: ServiceUnavailableError: code=None err_code=None description='None'

Runtime environment

Operating system information:

uname -a
Linux pop-os 6.16.3-76061603-generic #202508231538~1761055796~22.04~ba79424 SMP PREEMPT_DYNAMIC Tue O x86_64 x86_64 x86_64 GNU/Linu

Python version

python --version
Python 3.10.12

Docker info:

docker info
Client: Docker Engine - Community
 Version:    28.5.1
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.9.11
    Path:     /home/jackburridge/.docker/cli-plugins/docker-ai
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.29.1-desktop.1
    Path:     /home/jackburridge/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.40.3-desktop.1
    Path:     /home/jackburridge/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.45
    Path:     /home/jackburridge/.docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Docker Inc.)
    Version:  v0.2.0
    Path:     /home/jackburridge/.docker/cli-plugins/docker-desktop
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.31
    Path:     /home/jackburridge/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     /home/jackburridge/.docker/cli-plugins/docker-init
  mcp: Docker MCP Plugin (Docker Inc.)
    Version:  v0.28.0
    Path:     /home/jackburridge/.docker/cli-plugins/docker-mcp
  offload: Docker Offload (Docker Inc.)
    Version:  v0.5.20
    Path:     /home/jackburridge/.docker/cli-plugins/docker-offload
  pass: Docker Pass Secrets Manager Plugin (beta) (Docker Inc.)
    Version:  v0.0.11
    Path:     /home/jackburridge/.docker/cli-plugins/docker-pass
  sandbox: Docker Sandbox (Docker Inc.)
    Version:  v0.6.0
    Path:     /home/jackburridge/.docker/cli-plugins/docker-sandbox
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /home/jackburridge/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.18.3
    Path:     /home/jackburridge/.docker/cli-plugins/docker-scout

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 22
 Server Version: 29.0.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Discovered Devices:
  cdi: docker.com/gpu=webgpu
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: fcd43222d6b07379a4be9786bda52438f0dd16a1
 runc version: v1.3.3-0-gd842d771
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.54-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 3.662GiB
 Name: docker-desktop
 ID: 9d39b93b-1e69-4b12-b413-35c7c9175803
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///home/jackburridge/.docker/desktop/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Python packages:

pip freeze
certifi==2025.11.12
charset-normalizer==3.4.4
docker==7.1.0
idna==3.11
nats-py==2.12.0
python-dotenv==1.2.1
requests==2.32.5
testcontainers==4.13.3
typing_extensions==4.15.0
urllib3==2.5.0
wrapt==2.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions