I am trying to write a generic script for restarting a Docker container. I set the container name, repo and run options in variables at the start. The run options are a multiline variable to make it easier to read/edit i.e.
runOptions='
-e PUID=1001 -e PGID=1001
-e TZ=Europe/London
--health-cmd "curl -sf https://example.com || exit 1"
--health-interval 1m
--health-timeout 10s
--health-retries 1'
If I echo the final command it looks fine BUT when I execute the command in the script it fails.
${containerRuntime} run -d --name ${containerName} ${runOptions} ${containerRepo}
gives:
Error: unknown shorthand flag: 's' in -sf
See 'podman run --help'
I assume the issue is with the double quotes not being interpreted correctly when run via the script. I tried escaping the double quotes but the behaviour is the same.
Any ideas how I can get it to work?
Thank you