Issue with indexing in Docker container (cursor-agent)

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug


Subject: Cursor Agent Indexing Fails with Authentication Error in Docker Container

Description:

I’m experiencing an issue where cursor-agent fails to index the codebase when running inside a Docker container. The agent returns an authentication error despite having a valid CURSOR_API_KEY configured.

Error logs from root/.cursor/projects/code-src/worker.log:

[info] runServer
[info] Indexing now
[info] Getting tree structure for workspacePath=/code-src
[error] Indexing failed ERROR: ConnectError: [unauthenticated] Error
    at Yg (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-y05a0qn2.js:129:6053)
    at z0 (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-y05a0qn2.js:129:6458)
    at next (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-y05a0qn2.js:129:15541)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-jhmwpaha.js:4:7432
    at async Object.unary (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-y05a0qn2.js:129:14544)
    at async Object.fastRepoInitHandshakeV2 (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-ahprgwys.js:1:13861)
    at async TH.index (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-my3wxw98.js:2:9905)
    at async I.indexNow (file:///root/.local/share/cursor-agent/versions/2025.09.04-fc40cd1/index-jhmwpaha.js:2:7135)
[error] Indexing run failed ERROR: undefined
[info] Indexing finished

Environment Setup:

My cli-config.json:

{
  "permissions": {
    "allow": [
      "Shell(*)",
      "Read(*)",
      "Write(*)"
    ],
    "deny": []
  },
  "version": 1,
  "editor": {
    "vimMode": false
  },
  "model": {
    "modelId": "default",
    "displayModelId": "auto",
    "displayName": "Auto",
    "displayNameShort": "Auto",
    "aliases": [
      "auto"
    ]
  },
  "hasChangedDefaultModel": false,
  "privacyCache": {
    "ghostMode": true,
    "privacyMode": 2,
    "updatedAt": 1757345127362
  }
}

Dockerfile:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN set -eux; \
    rm -rf /var/lib/apt/lists/*; \
    mkdir -p /var/lib/apt/lists/partial; \
    apt-get update -o Acquire::Retries=3 -o Acquire::http::No-Cache=true -o Acquire::http::Pipeline-Depth=0; \
    apt-get install -y --no-install-recommends \
        curl \
        bash \
        ca-certificates \
        git \
        jq; \
    apt-get clean; \
    rm -rf /var/lib/apt/lists/*

# Install Cursor CLI (cursor-agent)
RUN curl https://cursor.com/install -fsS | bash

# Ensure Cursor CLI is on PATH for all shells
ENV PATH="/root/.local/bin:$PATH"
RUN echo 'export PATH="$HOME/.local/bin:$PATH"' >> /root/.bashrc

WORKDIR /workspace

CMD ["bash", "-lc", "echo 'Cursor CLI ready. Use: docker exec -it cursor_cli bash'; tail -f /dev/null"]

Docker Compose configuration:

cursor:
  build:
    context: ./cursor-cli
    dockerfile: Dockerfile
  container_name: cursor_cli
  env_file:
    - .env
  environment:
    - CURSOR_API_KEY=${CURSOR_API_KEY}
    - CODE_SEARCH_ROOTS=/code-src
    - NO_PROXY=api2.cursor.sh,api3.cursor.sh,repo42.cursor.sh,api4.cursor.sh,us-asia.gcpp.cursor.sh,us-eu.gcpp.cursor.sh,us-only.gcpp.cursor.sh,marketplace.cursorapi.com,cursor-cdn.com,downloads.cursor.com,anysphere-binaries.s3.us-east-1.amazonaws.com
    - no_proxy=api2.cursor.sh,api3.cursor.sh,repo42.cursor.sh,api4.cursor.sh,us-asia.gcpp.cursor.sh,us-eu.gcpp.cursor.sh,us-only.gcpp.cursor.sh,marketplace.cursorapi.com,cursor-cdn.com,downloads.cursor.com,anysphere-binaries.s3.us-east-1.amazonaws.com
  working_dir: /workspace
  volumes:
    - .:/workspace
    - ./tools/cursor/cli-config.json:/root/.cursor/cli-config.json:ro
    - "/path/to/repo:/code-src:rw"
  command: ["bash", "-lc", "echo 'Cursor ready. Try: cursor-agent status'; tail -f /dev/null"]

What I’ve tried:

  1. Verified CURSOR_API_KEY is properly set and accessible in the container
  2. Set proper permissions in cli-config.json to allow all operations
  3. Added Cursor domains to NO_PROXY environment variables
  4. Installed ca-certificates in the container
  5. Running cursor-agent status shows the agent is installed but indexing fails

Additional Information:

  • cursor-agent version: 2025.09.04-fc40cd1
  • Running on Ubuntu 22.04 base image in Docker
  • The same API key works fine when used outside of Docker
  • Network connectivity from container to external services is working

Questions:

  1. Are there specific network requirements or ports that need to be exposed for cursor-agent to authenticate properly in a Docker environment?
  2. Is there additional configuration needed for cursor-agent to work inside containers?
  3. Are there any known issues with the authentication handshake (fastRepoInitHandshakeV2) when running in containerized environments?

Any guidance on resolving this authentication error would be greatly appreciated.

Thank you!


Steps to Reproduce

Docker instructions are attached.
Issue can be reproduced by just requesting anything via cursor-agent “Prompt”

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Cursor CLI Version: 2025.09.04-fc40cd1

For AI issues: which model did you use?

Auto