I don't understand why my entrypoint can't execute my command. My entrypoint look like this:
#!/bin/bash
...
exec "$@"
My script is existing I can run it when I go inside my container:
drwxrwxrwx 1 root root 512 mars 25 09:07 .
drwxrwxrwx 1 root root 512 mars 25 09:07 ..
-rwxrwxrwx 1 root root 128 mars 25 10:05 entrypoint.sh
-rwxrwxrwx 1 root root 481 mars 25 09:07 init-dev.sh
-rwxrwxrwx 1 root root 419 mars 25 10:02 migration.sh
root@0c0062fbf916:/app/scripts# pwd
/app/scripts
And when I run my container : docker run my_container "scripts/migration.sh"
I got this error:
scripts/entrypoint.sh: line 8: /app/scripts/migration.sh: No such file or directory
I have the same error if I just run ls -all
docker run my_container "ls -all"
exec: ls -all: not found
I'm switching linux to windows <-> windows to linux so I checked to change lf to crlf but there is no changes
CodePudding user response:
Your first command doesn't work because your scripts are in /app/scripts
(note the plural), but you're trying to run run script/migration.sh
. Additionally, it's not clear what the current working directory is in your container: even if you wrote scripts/migration.sh
, that would only work if either (a) your Dockerfile
contains a WORKDIR /app
, or if your docker run
command line includes -w /app
. You would be better off using a fully qualified path:
docker run mycontainer /app/scripts/migration.sh
Your second example (docker run my_container "ls -all"
) is over-quoted and would never work. You need to write docker run my_container ls -all
, except that -all
isn't actually an option that ls
accepts, although it will work by virtue of being the combination of the -a
and -l
options.