【问题标题】:Docker: E: Unable to locate package mysql-client —-no-install-recommendsDocker: E: Unable to locate package mysql-client —-no-install-recommends
【发布时间】:2018-10-03 10:24:30
【问题描述】:

我正在关注本教程: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 中有语法错误,因为您复制了文章中的代码。该选项必须带有此符号--。试试这个mysql-client  --no-install-recommends

标签: php laravel docker


【解决方案1】:

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

把Dockerfile或者根据文章app.dockerfile改成:

FROM php:7.2.2-fpm RUN apt-get update && apt-get install -y mysql-client \ && docker-php-ext-install pdo_mysql

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

【讨论】:

  • 太棒了!此外,我建议您始终阅读 Dockerfile 文件,大部分时间它们正在运行命令来安装库、依赖项、服务等,就像您在非容器化环境(基于 Unix)中所做的那样。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-30
  • 1970-01-01
  • 1970-01-01
  • 2019-09-29
  • 1970-01-01
  • 1970-01-01
  • 2022-12-27
相关资源
最近更新 更多