You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 startup
What I have tried:
mount script into cont-init: ./script.sh:/etc/cont-init.d/99-script.sh
result: Container starts but script fails Command 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:):
#!/bin/bash
ip route del default
ip route add default via ${VPN_CONT_IP}
ip route add ${HOST_LAN:-10.0.1.0/24} via 10.0.10.1
wanip=$(curl icanhazip.com)
echo "##############################################################"
echo "# Now routing through ${VPN_CONT_IP} to WAN IP $wanip. #"
echo "##############################################################"
any suggestions on how I can accomplish this are greatly appreciated
The text was updated successfully, but these errors were encountered:
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 fails
Command 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.shresult:
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
The text was updated successfully, but these errors were encountered: