I have a script that restarts a docker container.
- If I execute that script as root it works perfectly.
- I have set sudoers so other users do not need a password to execute this script as root
- I want my webappliaction (php based) to be able to execute it if I click a button
But here is the problem.
My PHP file includes:
<?php echo passthru("sudo /volume1/web/VPN/vpnSwitchLocation.sh $location 2>&1"); ?>
And the script executes without password! But within the script there is a docker command
docker run ...
When ever I call the script from php this error occurs:
docker: command not found
But if I execute it without sudo (manually from the shell) it works perfectly fine. So my question is:
how can I execute scripts with sudo within PHP which are containin docker commands?
Source: Docker Questions