sudo behaves different the normal script execution

  docker, php, shell, sudo, synology

I have a script that restarts a docker container.

  1. If I execute that script as root it works perfectly.
  2. I have set sudoers so other users do not need a password to execute this script as root
  3. 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:

    echo passthru("sudo /volume1/web/VPN/ $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?

Best regards

Source: Docker Questions