Docker run command - invalid command

hi
this is my first post
When I use this command
“docker run --name xx --rm container-name ls”
I get the same answer " invalid command: “ls” "
If when I use this command
“docker exec -ti container-name bash” and then in bash i enter “ls” the command works.
(This issue is not just for ls command and this is the case for all simple commands)

You might want to check the entrypoint and command of the image:

me@docker:~$ docker inspect --format 'Entrypoint:{{.Config.Entrypoint}}, Cmd: {{.Config.Cmd}}' ubuntu
Entrypoint:[], Cmd: [/bin/bash]

It really depends on the entrypoint:

# image default = no entrypoint script
me@docker:~$ docker run -ti --rm ubuntu ls
bin   dev  home  lib32  libx32  mnt  proc  run   srv  tmp  var
boot  etc  lib   lib64  media   opt  root  sbin  sys  usr

# set entrypoint to bash, ls is an argument for bash
me@docker:~$ docker run -ti --rm --entrypoint bash ubuntu ls
/usr/bin/ls: /usr/bin/ls: cannot execute binary file

# set entrypoint to bash, -c ls is an argument for bash
me@docker:~$ docker run -ti --rm --entrypoint bash ubuntu -c ls
bin   dev  home  lib32  libx32  mnt  proc  run   srv  tmp  var
boot  etc  lib   lib64  media   opt  root  sbin  sys  usr