When a docker run fails, the first question is whether Docker or your command is to blame. The exit code answers it before you read any logs.
The docs describe three special codes. 125 means the error is with the Docker daemon itself, for example an unknown flag. 126 means the command inside the container exists but cannot be invoked. 127 means the command cannot be found. Any other code is the exit code of the container command itself.
docker run busybox foo; echo $?
docker: Error response from daemon: Container command 'foo' not found or does not exist.
127
docker run busybox /etc; echo $?
docker: Error response from daemon: Container command '/etc' could not be invoked.
126
So 127 usually means a typo, a missing binary or a wrong --entrypoint, and 126 often means a file that is not executable or a folder given where a program should be. A 125 sends you to the flags: run docker run --help and read what you typed. Anything else, like the 3 from docker run busybox /bin/sh -c 'exit 3', comes from the application, and then docker logs is where to look.
The app can use these numbers too. A script inside the container that ends with exit 127 looks the same as a missing command, so check the error message that Docker prints next to the code, as in the examples above.
Further reading: Docker run: exit status