Why cannot I use PHP to call the Docker command?

Source: Internet
Author: User
{Code ...} result {code ...} use php. index. phpsystem (& quot; sudodocker... & quot;) is executable and cannot be executed when accessed using a browser

  

Result

total 24drwxr-xr-x 2 root root 4096 Jun 23 16:24 .drwxr-xr-x 3 root root 4096 Jun 23 15:30 ..-rw-r--r-- 1 root root    1 Jun 23 15:42 index.html-rw-r--r-- 1 root root  215 Jun 23 16:24 index.php

Use php./index. php
System ("sudo docker...") is executable
You cannot execute the command if you use a browser to access it.

Reply content:

  

Result

total 24drwxr-xr-x 2 root root 4096 Jun 23 16:24 .drwxr-xr-x 3 root root 4096 Jun 23 15:30 ..-rw-r--r-- 1 root root    1 Jun 23 15:42 index.html-rw-r--r-- 1 root root  215 Jun 23 16:24 index.php

Use php./index. php
System ("sudo docker...") is executable
You cannot execute the command if you use a browser to access it.

It should be caused by insufficient php permissions. you can print out the status code returned after system execution and use the exec command to view the specific returned results.

You are executing www users in the browser. if you use the php command line (php cli) for execution, it is your current user, the current user has the permission to run successfully.

The reason should be that the permission is insufficient, which has been clearly stated upstairs.

The other solution is that php can directly use the Docker Remote API to operate on docker.
See http://www.open-open.com/lib/view/open1419921028828.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.