英文:
How to containerize legacy app with PHP version 5.4.x?
问题
我是新手PHP开发者,已经卡住两天,仅仅是为了在我的本地设置PHP版本。我试图继续构建使用PHP版本5.4.45的遗留应用程序。首先,我一直在尝试从这些来源安装PHP版本5.4.45到我的MacOS Ventura(13.4.1)设备上。在我提取、configure
和make
之后,似乎与我的设备存在兼容性问题。
由于我整天都卡住了,我尝试构建一个容器来运行遗留应用程序,使用Docker。我按照这个指南操作,以下是我的Docker文件:
FROM php:5.4-apache-stretch
RUN docker-php-ext-install -j$(nproc) mysqli opcache
ADD php.ini /usr/local/etc/php.ini
并执行Docker命令docker build -t first-php-docker .
,结果出现错误failed to solve: php:5.4-apache-stretch: failed to do request: Head "https://registry-1.docker.io/v2/library/php/manifests/5.4-apache-stretch": EOF
,似乎源不再存在。
问题:
-
如何确保
php:5.4-apache-stretch
镜像是否仍然存在? -
如果它仍然存在,如何使用该镜像作为基础构建容器?
英文:
I am new to PHP development and stuck for two days just to set up the PHP version in my local. I am trying to continue the legacy app that builds using PHP version 5.4.45. Firstly, I have been attempting to install PHP version 5.4.45 on my MacOS Ventura (13.4.1) devices from these sources. After I extract, configure
, and make
it seems that it has compatibility issues with my devices.
Since I have been stuck all day, I try to build a container to run the legacy app using Docker. I follow this guide and here is my docker file:
FROM php:5.4-apache-stretch
RUN docker-php-ext-install -j$(nproc) mysqli opcache
ADD php.ini /usr/local/etc/php.ini
and execute the docker command docker build -t first-php-docker .
and it yields the error failed to solve: php:5.4-apache-stretch: failed to do request: Head "https://registry-1.docker.io/v2/library/php/manifests/5.4-apache-stretch": EOF
and it seems the source is doesn't exist anymore.
Question:
-
How to make sure whether the
php:5.4-apache-stretch
image still exists or not?- If it still exists, how to build a container with that image as the base?
答案1
得分: 1
只有一个适用于 Docker Hub 的 PHP 5.4 + Apache 镜像php:5.4-apache。
此镜像仅适用于 AMD64 平台,因此如果在 M1/M2 Mac 上构建,您需要指定平台。
在添加您的 php.ini
文件时,您还应该使用预配置的 PHP_INI_DIR
环境变量。请参阅配置。
FROM --platform=linux/amd64 php:5.4-apache
# ...
ADD php.ini "$PHP_INI_DIR/php.ini"
如果没有上述的 --platform
规范,您将不断收到如下警告:
警告:所请求的镜像平台(linux/amd64)与检测到的主机平台(linux/arm64/v8)不匹配,且没有请求特定的平台
请注意,此镜像使用了 Debian Jessie 基础镜像。
英文:
There's currently only one PHP 5.4 + Apache image available on Docker Hub
This image is only built for the AMD64 platform so you'll need to specify that if you're building on an M1 / M2 Mac.
You should also use the pre-configured PHP_INI_DIR
environment variable when adding your php.ini
file. See Configuration.
FROM --platform=linux/amd64 php:5.4-apache
# ...
ADD php.ini "$PHP_INI_DIR/php.ini"
Without the above --platform
specification, you will constantly get warnings like
> WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Note, this uses a Debian Jessie base image.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论