I use same token to authenticate on my laptop and again inside a docker container, but authentication fails inside the container. I want to run cli inside container full autonomously , at scale.
Steps to Reproduce
Dockerfile
FROM ubuntu:22.04
# Install curl (required for Cursor installation)
RUN apt-get update && \
apt-get install -y curl && \
rm -rf /var/lib/apt/lists/*
# Install Cursor CLI using official installation method
# See https://cursor.com/docs/cli/installation
RUN curl https://cursor.com/install -fsS | bash
# Add ~/.local/bin to PATH (where cursor-agent is installed)
ENV PATH="/root/.local/bin:${PATH}"
# Verify installation
RUN cursor-agent --version || echo "Cursor CLI installed (may need auth setup)"
# Default command
CMD ["cursor-agent", "-p", "--api-key", "$CURSOR_API_KEY", "2 + 2 ?"]
To reproduce the error:
docker build -f Dockerfile -t cursor-minimal:latest .
# CURSOR_API_KEY should be set on the host
docker run -it -e CURSOR_API_KEY cursor-minimal:latest
Unfortunately it does not work for me. The code snippets I’ve provided are just to reproduce the error, when I run shell inside the container, set CURSOR_API_KEY , and try the cursor-agent, it still fails with the same error.
Hi @Mohammad_Mazraeh , could you try solution 2 again? Note that you would have to rebuild the dockerimage after changing the CMD argument. This should work, assuming your CURSOR_API_KEY is set in your host environment, as the agent reads this variable.
Thanks @ravirahman for the reply. I have tried #2. Please check the screenshot for the same test on host and inside container (I’m using bash to enter container, so CMD is being overriden)
I just used Ubuntu 24 as base image to be able to install cursor-agent 2025.11.25-e276529 and the same issue still persists.
Even if I run just cursor-agent without any parameters or prompts, I’m getting the same error.
The other issue is cursor-agent login timeouts in a few seconds inside docker container (getting fixed does not solve my problem and I still need API based authentication)
This error indicates that the API key was provided, but could not be used to log in. Could you verify that it was supplied correctly? If that doesn’t work, could you try making a new API key?
@ravirahman in the attached screenshot to the above message, I’m using same API key on the host (my laptop) and it seems to be working. same series of commands inside the container doesn’t work. I’ve tested a few ways of providing the API key.
Did you happen to get a chance and see if you can reproduce the error?
@ravirahman@deanrie Did you get a chance to try and reproduce the error? I asked my colleagues as well and I’m confident it’s an issue with cursor authentication inside a docker container.