I’m just trying to script deleting and re-adding a Pihole container, and it keeps failing on the /container/add, but I don’t know why. Can someone help? This is my first script so I am sure it’s something stupid.
/container/stop [find tag=pihole/pihole:latest]
:log info "Stopped";
:delay 30s;
:log info "removing...";
/container/remove [find tag=pihole/pihole:latest]
:log info "adding...";
/container/add remote-image=pihole/pihole:latest dns=192.168.4.1 domain-name=elbonia envlist=pihole_envs hostname=pihole interface=veth1 mounts=etc_pihole,dnsmasq_Pi-hole root-dir=/usb1/docker/pihole-root start-on-boot=yes
:log info "added";
:delay 90s;
:log info "starting";
/container/start [find tag=pihole/pihole:latest]
The error I get in the log is:
But if I copy that exact /container/add line into the terminal, the container adds just fine. What’s going on here? I have given the script read and write permissions. Does it need something else?
It may be the starting slash in “root-dir” – I recall it doesn’t take one… so maybe try removing the starting / from the path:
root-dir=usb1/docker/pihole-root
Also, it may not be stopped even after 30 seconds is other possibility here… logs might show if that’s the case. To avoid :delay X, you can use a loop to read the status in some loop, if you want to be sure it stopped, etc. before proceeding (e.g. rather than using :delay X). I have a unforentently complex example of how to do this here: https://github.com/tikoci/serial2http/blob/main/SERIAL2HTTP.rsc
It appears to be a permissions thing. If I enable all the script permissions it works fine. I’m not sure which one (and don’t feel like trying them one by one).
Of course now I’ve modified the script to not need the delays and once again it doesn’t work (same error).