php - Docker:E:无法找到软件包 mysql-client —-no-install-recommends

标签 php laravel docker

我正在关注本教程:Laravel 5.6 in Docker with PHP 7.2, NGINX 1.10 and MySQL 5.7

这基本上是对此的更新:Laravel + Docker Part 1 — setup for Development

但是当我运行时

docker-compose up

我收到这个错误

E: Unable to locate package mysql-client —-no-install-recommends
ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y mysql-client —-no-install-recommends  && docker-php-ext-install pdo_mysql' returned a non-zero code: 100

完整输出

Creating network "pulzu_default" with the default driver
Building app
Step 1/2 : FROM php:7.2.2-fpm
 ---> 60245f64ed12
Step 2/2 : RUN apt-get update && apt-get install -y mysql-client —-no-install-recommends  && docker-php-ext-install pdo_mysql
 ---> Running in cefd70564b31
Get:1 http://security.debian.org stretch/updates InRelease [94.3 kB]
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:3 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:5 http://security.debian.org stretch/updates/main amd64 Packages [468 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [12.1 kB]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [9530 kB]
Fetched 10.3 MB in 2s (4142 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package mysql-client —-no-install-recommends
ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y mysql-client —-no-install-recommends  && docker-php-ext-install pdo_mysql' returned a non-zero code: 100

有人知道如何修复它吗?

最佳答案

该镜像缺少能够安装mysql-client的依赖项,这是由--no-install-recommends标志引起的。默认情况下,Ubuntu 安装推荐但不建议的软件包。使用 --no-install-recommends,仅安装主要依赖项(Depends 字段中的包)。

Dockerfile或根据文章app.dockerfile更改为:

来自 php:7.2.2-fpm 运行 apt-get update && apt-get install -y mysql-client\ && docker-php-ext-install pdo_mysql

并且您应该能够构建镜像,因此 docker-compose up 命令可以工作。

关于php - Docker:E:无法找到软件包 mysql-client —-no-install-recommends,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49979973/

相关文章:

php - 您如何使用值中的逗号EXPLODE CSV 行?

php - 自动维护/"We will be back"页

php - 图片上传/Laravel 将图片存储为 .tmp 而不是 .img 文件

docker - 运行短期脚本后坚持Docker容器

docker - 通过 docker compose 在 digital ocean 上使用 docker gcplogs(Google Cloud Logging 驱动程序)

php - 如何在 PHP 中获取与平台无关的目录分隔符?

PHP:goto 和 while 等其他控制结构有什么区别

php - Laravel 如何约会减去日期并获取分钟数

Laravel集体使用onclick

windows - 用于服务发现的 Docker DNS 按名称解析 Windows 容器地址的工作效果不一致