It works in docker compose because compose handles relative paths for the volumes, the docker CLI doesn't.
You can achieve this by doing something like
docker run -v $(pwd):/data ...
pwd
is a command that returns the current path as an absolute path, you can just run it by itself to see this. $() syntax is to execute the inner command separately before the shell runs the rest of it. (Same as backticks, just better practice)
I imagine that wouldn't work on windows, but it would on either osx, Linux or wsl.
Generally speaking, if you need the file system access and your CLI requires some setup, I'd recommend either writing it in a statically compiled language (e.g. golang, rust) or researching how to compile a python script into an executable.
If you're just mounting your script in the container - you're better off adding it directly at build time.