I have to execute scripts inside a docker container, example
composer install
or
bin/another-script another-script-arg-1 another-script-arg-2
in order to execute this command inside the container I have to execute something like (using docker-compose)
sudo docker-compose exec container-name sh -c 'bin/another-script another-script-arg-1 another-script-arg-2'
I want write a simple script that allow me save some typos and extra strokes for running just variances of the previous command, so I wrote an script
#!/usr/bin/env bash
sudo docker-composer exec container-name sh -c "'bin/another-script $@'"
So I can execute outside, just
bin/another-script another-script-arg-1 another-script-arg-2
but doesnt work, just tellme something like 'bin/another-script' not found (inside container). I know this happens when the single quotes are not passed around the -c '' part. I have tried different stuff
#!/usr/bin/env bash
sudo docker-composer exec container-name sh -c \'bin/another-script $@\'
or
#!/usr/bin/env bash
sudo docker-composer exec container-name sh -c "'bin/another-script $@'"
or
#!/usr/bin/env bash
sudo docker-composer exec container-name sh -c "'"bin/another-script "$@""'"
Edit: the internal path of the script bin/another-script
is not a problem because container move to the working dir, any case I've tested with the absolute path getting the same result /app/bin/another-script
#!/usr/bin/env bash
sudo docker-composer exec container-name sh -c "'/app/bin/another-script $@'"
but nothing works, any advice?