我正在恢复一个仍然使用PHP5.6和mysql_connect的旧网站,以更新其代码。
我打算用PHP 5.6设置一个docker环境,以确保一切正常工作,然后再进行急需的更新。
但是我正在努力安装mysql驱动程序。
这是我的docker-compose.yml
version: '3'
services:
db:
image: mysql:5.5
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: "edited for privacy"
MYSQL_DATABASE: "edited for privacy"
MYSQL_USER: "edited for privacy"
MYSQL_PASSWORD: "edited for privacy"
php:
depends_on:
- db
build: .
volumes:
- ./:/var/www/html
ports:
- "8000:80"
restart: always
volumes:
db_data: {}
字符串
对于第一个dockerfile,我得到了以下错误
FROM php:5.6-apache
RUN apt-get install mysql-server mysql-client php5-mysql
RUN a2enmod rewrite
docker compose up -d
[+] Building 1.2s (6/7)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 139B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/php:5.6-apache 0.8s
=> [auth] library/php:pull token for registry-1.docker.io 0.0s
=> CACHED [1/3] FROM docker.io/library/php:5.6-apache@sha256:0a40fd273961b99d8afe69a61a68c73c04bc0caa9de384d3b2dd9e7986eec86d 0.0s
=> => resolve docker.io/library/php:5.6-apache@sha256:0a40fd273961b99d8afe69a61a68c73c04bc0caa9de384d3b2dd9e7986eec86d 0.0s
=> ERROR [2/3] RUN apt-get install mysql-server mysql-client php5-mysql 0.3s
------
> [2/3] RUN apt-get install mysql-server mysql-client php5-mysql:
#0 0.292 Reading package lists...
#0 0.296 Building dependency tree...
#0 0.296 Reading state information...
#0 0.297 E: Unable to locate package mysql-server
#0 0.297 E: Unable to locate package mysql-client
#0 0.297 E: Unable to locate package php5-mysql
------
failed to solve: executor failed running [/bin/sh -c apt-get install mysql-server mysql-client php5-mysql]: exit code: 100
的数据
我以为我必须先更新,但后来我得到了这个错误,我不知道该怎么办。
FROM php:5.6-apache
RUN apt-get update && apt-get install -y \
mysql-client \
mysql-server \
php5-mysql
RUN a2enmod rewrite
docker compose up -d
[+] Building 0.7s (5/6)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 189B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/php:5.6-apache 0.4s
=> CACHED [1/3] FROM docker.io/library/php:5.6-apache@sha256:0a40fd273961b99d8afe69a61a68c73c04bc0caa9de384d3b2dd9e7986eec86d 0.0s
=> => resolve docker.io/library/php:5.6-apache@sha256:0a40fd273961b99d8afe69a61a68c73c04bc0caa9de384d3b2dd9e7986eec86d 0.0s
=> ERROR [2/3] RUN su apt-get update -q && apt-get install -y mysql-client mysql-server php5-mysql 0.3s
------
> [2/3] RUN su apt-get update -q && apt-get install -y mysql-client mysql-server php5-mysql:
#0 0.281 su: invalid option -- 'q'
#0 0.281 Usage: su [options] [LOGIN]
#0 0.281
#0 0.281 Options:
#0 0.281 -c, --command COMMAND pass COMMAND to the invoked shell
#0 0.281 -h, --help display this help message and exit
#0 0.281 -, -l, --login make the shell a login shell
#0 0.281 -m, -p,
#0 0.281 --preserve-environment do not reset environment variables, and
#0 0.281 keep the same shell
#0 0.281 -s, --shell SHELL use SHELL instead of the default in passwd
#0 0.281
------
failed to solve: executor failed running [/bin/sh -c su apt-get update -q && apt-get install -y mysql-client mysql-server php5-mysql]: exit code: 2
我不知道下一步该怎么办,任何帮助都是非常受欢迎的。
1条答案
按热度按时间nxowjjhe1#
它似乎可以按照https://prototype.php.net/versions/5.6/install/docker上的说明使用此dockerfile
字符串