简体   繁体   English

Docker 和 php-cli

[英]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.我已经安装了PHP 7 (php-fpm 和 php-cli),我的应用程序在新的PHP上运行良好,但测试( phpunit )没有,因为一些扩展还没有更新。

So I'm thinking to use/create some docker container with PHP 5.6 that would replace my system's (host) php-cli .所以我正在考虑使用/创建一些带有PHP 5.6的 docker 容器,它将取代我系统的(主机) php-cli

For example, if I build container called php56 from Dockerfile that looks like this:例如,如果我从Dockerfile构建名为php56的容器,如下所示:

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.我从Docker容器中获取版本信息,所以 docker 的php-cli 5.6 正在工作。 So I wan't to put docker run command in所以我不想把docker run命令放进去

/usr/bin/php

so that host use php-cli from docker container.以便主机使用 docker 容器中的 php-cli (then php -v would give me PHP 5.6 info not PHP 7.0 version info) (然后php -v会给我PHP 5.6信息而不是PHP 7.0版本信息)

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.如果无法像这样解决它,请向我推荐其他解决方案。

I did something that looks like what you're looking for: https://github.com/jclaveau/docker-php-multiversion我做了一些看起来像你正在寻找的东西: 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.这将添加一个 php shell 脚本,该脚本将运行一个包含自 5.6 以来所有可用 PHP 版本的 docker 映像。

You can then run php 5.6 vendor/bin/phpunit or php 7.4 vendor/bin/phpunit , etc.然后,您可以运行php 5.6 vendor/bin/phpunitphp 7.4 vendor/bin/phpunit等。

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在我的 SSD 崩溃后,我将它嵌入到 Docker 映像中,在那里我丢失了所有 php.ini 配置,所以只要你安装了 Docker.io,它就可以工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM