Open tigerkzr opened 1 year ago
Similar issue here, would like to set WAN and incoming port at container startup. I could probably achieve that by running a script at startup.
I agree that this should be done properly, but mounting a shell script into /etc/cont-init.d worked fine for me. Try to add the full path to the curl command like /usr/local/bin/curl, it's possible that the s6-init is not appending all the known bin locations on PATH environment variable.
Is there a way of running a custom init script at container start?
the gist: At container startup, set a default route within the torrent container so that traffic goes through through my VPN container that uses IP masquerade. (I am avoiding setting the network mode to container or service)
how I normally accomplish this: Using linuxserver images, one can just mount a script into the container at
./script/dir:/custom-init-script.d
and the container will run every script there at startupWhat I have tried: mount script into cont-init:
./script.sh:/etc/cont-init.d/99-script.sh
result: Container starts but script failsCommand line is not complete. Try option "help"
/var/run/s6/etc/cont-init.d/99-script.sh: line 7: curl: command not found
mount script directory into container and use
command
in docker compose 'command: /script/dir/script.sh result: Script works but the container goes on a restart/terminate loop.I can run the script after container startup using docker exec, and it works, but this doesn't persist between restarts.
script I am trying to run(env vars are passed via docker compose
environment:
):any suggestions on how I can accomplish this are greatly appreciated