'shell script : container vs host

For Loop to start from 2nd argument behaving differently on container and host

#!/bin/bash 

for i in "${@:2}"
do  
        echo $i
done

Call:

script.sh 129 5 6 7

Output: Container: Alpine:Latest #skipping 2 characters

9 5 6 7

Host: Debian GNU/Linux #skipping 1st argument complete

5 6 7


Solution 1:[1]

i am not sure how you were able to run the above shell script into the alpine version.

#!/bin/bash 
for i in "${@:2}"
do  
        echo $i
done

as in script you are using #!/bin/bash which is not supported in the alpine.

Issue could be due the different interpreters, sh and bash which one you are using. Debian comes with bash while alpine uses sh by default.

you can quickly verify it using : docker pull alpine:latest

docker run -it alpine bash while docker run -it alpine sh will work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harsh Manvar