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

构建Laravel应用Docker镜像时遇oniguruma依赖缺失错误求助

Fixing "oniguruma not found" Error When Building Laravel Docker Image

Hey there, let's get that Docker build error sorted out quickly! The problem here is that the mbstring PHP extension depends on the oniguruma regex library, which isn't included in the base php:7 Docker image by default. When you try to install mbstring via docker-php-ext-install, it can't find the required oniguruma files, hence the error.

Here's the fix:

You just need to add the oniguruma development package (called libonig-dev in Debian/Ubuntu-based images) to your apt-get install command before installing the PHP extensions.

Modified Dockerfile:

FROM php:7
RUN apt-get update -y && apt-get install -y openssl zip unzip git libonig-dev
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo mbstring
WORKDIR /app
COPY app /app # this copies all the app files to a folder called `app`
RUN composer install
CMD php artisan serve --host=0.0.0.0 --port=8000
EXPOSE 8000

What changed?

  • Added libonig-dev to the list of packages installed via apt-get — this provides the header files and libraries needed to compile the mbstring extension.
  • All other steps remain the same as your original Dockerfile.

Now re-run your build command:

sudo docker build -t test .

This should resolve the "No package 'oniguruma' found" error and successfully build your Laravel Docker image.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:49:44