How does the php image docker run external PHP scripts?

< H2 > description < / H2 >

normal if PHP, is installed on the system, if you want to run a php script directly, php a.php can see the result.

how do I execute an a.php script if I use a docker build image?

Feb.28,2021

first do a directory mapping, map the directory where a.php is located to the inside of the container, and then execute it with cli inside the container


ssh-l loginname host-P port php a.php

for example, it is native. The port number is 8000 , and the user name is admin

.
ssh -l admin localhost -P 8000 a.php

docker run-- rm-it-v / (directory where a.php is located): / tmp php-docker (your docker image) sh-c "php / tmp/a.php"

-- rm single run container

if your php container is already running, exec it internally, or
docker exec-it container ID sh-c "php / (your mount directory) / a.php"


docker has a VOLUME that mounts the host directory, which you can set up.

Menu