'Docker and php-cli
I have installed PHP 7 (php-fpm and php-cli) and my app is working fine with new PHP, but tests (phpunit) don't because some extensions aren't updated yet.
So I'm thinking to use/create some docker container with PHP 5.6 that would replace my system's (host) php-cli.
For example, if I build container called php56 from Dockerfile that looks like this:
FROM ubuntu:15.10
RUN apt-get -y update && apt-get install -y php5-cli
ENTRYPOINT ["php"]
and run:
sudo docker run -it php56 -v
I'm getting version info from Docker container, so docker's php-cli 5.6 is working. So I wan't to put docker run command in
/usr/bin/php
so that host use php-cli from docker container. (then php -v would give me PHP 5.6 info not PHP 7.0 version info)
It's not best example, but I hope that you guys will understand what I'm trying to do. If it's not possible to solve it like this, please recommend me other solution.
Solution 1:[1]
I did something that looks like what you're looking for: https://github.com/jclaveau/docker-php-multiversion
This adds a php shell script which will run a docker image containing all available PHP versions since 5.6.
You can then run php 5.6 vendor/bin/phpunit or php 7.4 vendor/bin/phpunit, etc.
I embedded it inside a Docker image after a crash of my SSD where I lost all my php.ini configuration so as long as you have Docker.io installed, it would work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jean Claveau |
