S
S
Sergei Iamskoi2020-01-07 16:05:15
PHP
Sergei Iamskoi, 2020-01-07 16:05:15

How to call another in one container (php)?

There is a completely standard docker-compose: nginx, db, php, composer. The site is processed by a container with php 7.4 In this container, a script with the code exec_shell('php -f somescript.php') is launched. Is it possible to run php -f somescript.php through container from different php version i.e. separate from the one being launched? In general, launching an application in one container from another.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgenii Danilin, 2020-01-07
@danilinem

There are two ways to do this:
1. Mount (or use the http api) a Docker socket (/var/run/docker.sock) inside a container, and manage containers on the host machine, or use the . !!! HIGHLY DO NOT RECOMMEND!!!
2. Use Dind (docker in docker) image and install PHP on it and create child containers. I DO NOT RECOMMEND
In general, it is worth reviewing the infrastructure and architecture of the application to solve this problem, more safely and concisely.

G
great_77, 2020-01-08
@great_77

Referring to http.

S
Sergey Sokolov, 2020-01-08
@sergiks

I think it's worth raising a separate Docker container with the required PHP version, and accessing it.
Using the HTTP protocol - in the parent PHP script, use a regular curlor school script to file_get_contents()pull some local URL.
It can be RoadRunner or pull the NGINX already existing in another container, which will transfer requests to a certain URL not to the main PHP-FPM, but to the one with a different version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question