A
A
Andrew2021-05-28 14:59:58
PHP
Andrew, 2021-05-28 14:59:58

docker-composer - working example of running a server with two versions of php?

We have a site on opencart 2, which by default uses php version 5.6 (yes, it’s 5.6 because many modules there work only for it and not higher).

Also on the same server there are CRON tasks - other scripts that already use php 7.3 and work with the same database as opencart.

Please tell me a working example of docker-composer, so that by default a site working with 5.6 spins on port 80, but scripts (crown tasks and others) can be run in the console inside the container, having a choice.
Type:

php some_script.php - will run the default script on 5.6

and, for example
/opt/php73/bin/php some_script.php - will already run for 7.3


As I understand it, since it is considered good practice to add different versions of php to the container with different Image. It is not clear how then to organize an analogue of work, as on a regular server. Where different versions of php are available from one console at hand. after all, different images with different php are, in fact, different consoles. And it’s not convenient to test something and run it from different places in fact.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitriy, 2021-05-28
@bookamba

good practice one project - one docker config
so projects on php5.6 and php7.3 will each have its own version
so the steps are simple
1. go to the project folder
2. $ docker-compose up -d && docker-compose exec app bash
3. $ php some_script.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question