You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker构建Laravel环境报错:无法定位mysql-client包

Fixing "Unable to locate package mysql-client —-no-install-recommends" in Laravel Docker Setup

It looks like you’re hitting a couple of common pitfalls with your Dockerfile command. Let’s break down the issues and fix them:

1. Fix the Typo in the Command Flag

The most probable cause here is a typographical error in the --no-install-recommends flag. It seems you’ve accidentally used an em dash (—) instead of two regular hyphens (--). The shell interprets the em dash as part of the package name, which is why apt-get can’t find a package called mysql-client —-no-install-recommends.

Update your Dockerfile line to use proper double hyphens:

RUN apt-get update && apt-get install -y mysql-client --no-install-recommends && docker-php-ext-install pdo_mysql

2. Use the Correct Package Name (If Needed)

If fixing the typo doesn’t resolve the issue, the problem might be that the mysql-client package isn’t available under that name in your base image’s repository. For newer Debian/Ubuntu-based images, the official MySQL client is often provided via the default-mysql-client package instead.

Modify the command to use this package name:

RUN apt-get update && apt-get install -y default-mysql-client --no-install-recommends && docker-php-ext-install pdo_mysql

3. Optional: Clean Up to Reduce Image Size

To keep your Docker image lean, you can add commands to clean up the apt cache after installation (this helps avoid unnecessary bloat):

RUN apt-get update && \
    apt-get install -y default-mysql-client --no-install-recommends && \
    docker-php-ext-install pdo_mysql && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

After making these changes, rebuild your image with docker-compose build --no-cache and then run docker-compose up again. That should resolve the package-not-found error.

内容的提问来源于stack exchange,提问作者aasanchez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:01:49