laravel E: 包“mysql-client”在使用 docker compose 的 php-fpm 镜像构建中没有安装候选

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/57048428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:56:36  来源:igfitidea点击:

E: Package 'mysql-client' has no installation candidate in php-fpm image build using docker compose

laraveldockerdocker-composedockerfile

提问by surgiie

Im fairly new to docker and so im trying to learn more about it using a laravel project, im following this tutorial:

我对 docker 还很陌生,所以我尝试使用 laravel 项目了解更多关于它的信息,我正在关注本教程:

https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose?comment=77842

https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose?comment=77842

Ive adjusted the Dockerfile a bit from what the tutorial has but even the tutorial file causes the same result.

我已经从教程中稍微调整了 Dockerfile,但即使是教程文件也会导致相同的结果。

FROM php:7.3-fpm

# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Install dependencies
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    apt-get update && apt-get install -y mysql-client \


RUN npm install -g npm

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*


# Install extensions
RUN docker-php-ext-install pdo pdo_mysql

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www

# Copy existing application directory contents
COPY . /var/www

# Copy existing application directory permissions
COPY --chown=www:www . /var/www

# Change current user to www
USER www
# Set working directory
WORKDIR /var/www
# Expose port 9000 and start php-fpm server
EXPOSE 9000

CMD ["php-fpm"]

But i keep getting the following error when i run docker-compose up -d:

但是当我运行时,我不断收到以下错误docker-compose up -d

E: Package 'mysql-client' has no installation candidate
ERROR: Service 'app' failed to build: The command '/bin/sh -c curl -sL https://deb.nodesource.com/setup_10.x | bash - &&     apt-get update && apt-get install -y mysql-client     nodejs     build-essential     vim     git     curl' returned a non-zero code: 100

Am i missing something?

我错过了什么吗?

I expected this to work since i am running apt-get updatebefore installing mysql-client.

我希望这能工作,因为我apt-get update在安装之前正在运行mysql-client

Thanks.

谢谢。

回答by Yuan-Chen Ho

php:7.3-fpm now use Debian 10 (Buster) as its base imageand Buster ships with MariaDB, so just replace mysql-clientwith mariadb-clientshould fix it.

php:7.3-fpm 现在使用 Debian 10 (Buster) 作为其基础镜像,并且 Buster 随附 MariaDB,因此只需替换mysql-client为即可mariadb-client修复它。

回答by Emil Johnsson

If you still want to use the mysql client, it's called default-mysql-clientnow.

如果你还想使用mysql客户端,default-mysql-client现在就调用它。

回答by Patrick

I had the same issue in php:7.1-apache. Replacing mysql-clientwith mariadb-clientworks for me. Thank you.

我在php:7.1-apache. 更换mysql-clientmariadb-client我的作品。谢谢你。

回答by Mohammed Yassine CHABLI

php:7.2-apachetriggers the error as well, but I resolve it using php:7.2.18-apache

php:7.2-apache也会触发错误,但我使用 php:7.2.18-apache