This issue occurs only on the Windows version of Docker (I'm running Windows 10, docker 20.10.17). I have a shell script I'd like to run after my docker container is built.
It's named my_script.sh
and contains:
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket
My docker-compose.yml
file is:
version: '3.8'
services:
localstack:
image: localstack/localstack:latest
environment:
- DEFAULT_REGION=ap-northeast-2
...
ports:
- '4566-4583:4566-4583'
volumes:
- ./my_script.sh:/docker-entrypoint-initaws.d/my_script.sh
On Mac/Linux versions of Docker, this runs correctly when using docker-compose up
.
However, on the Windows version, it errors out with:
...
localstack_1 | Ready.
localstack_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initaws.d/my_script.sh
Parameter validation failed:ailed: s3://my-bucket
": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).*:(s3|s3-object-lambda):[a-z\-0-9]*:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-.]{1,63}$|^arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\-]{1,63}$"
It's as if Windows is running this script in its own Command Prompt rather than a shell.
How do I get Windows to interpret the script as a shell script?