Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

Why runing \Image::make under docker raised error?

I try to run under docker laravel 9.52.15 app with filament 2.17.52 and intervention/image 2.7 with Dockerfile.yml having :

  FROM php:8.1.6-apache
     ...
  RUN pecl install imagick \
    && docker-php-ext-enable imagick

  RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp  --with-jpeg

  RUN docker-php-ext-install gd

and running code :

        try {
            \Log::info(varDump($this->bgimageFileUrl, ' -0 BannerGeneratorBuilder->generate $this->bgimageFileUrl::'));
            $this->bgImageObject = \Image::make($this->bgimageFileUrl);
        } catch (\Intervention\Image\Exception\NotReadableException $e) {
            \Log::info(varDump($e->getMessage(), ' -1 BannerGeneratorBuilder->generate $e->getMessage()::'));
            return $this;
        }

image is not displayed and I see errors in log file :

[2023-10-21 14:36:58] production.INFO: scalar => (string) : -0 BannerGeneratorBuilder->generate $this->bgimageFileUrl:: : http://127.0.0.1:8085/storage/filament_banners_media/2/blue_light_1.png
[2023-10-21 14:36:58] production.INFO: scalar => (string) : -1 BannerGeneratorBuilder->generate $e->getMessage():: : Unable to init from given url (http://127.0.0.1:8085/storage/filament_banners_media/2/blue_light_1.png).
[2023-10-21 14:36:58] production.INFO: NULL : -10 $response:: : NULL

But if to copypaste image http://127.0.0.1:8085/storage/filament_banners_media/2/blue_light_1.png into browser - it is rendered ok.

looking at output of php info I see (I have found a hint that this option is important) :

allow_url_fopen = On 

Sure, I have run

php artisan storage:link 

priorly - images which are saved under storage are shown ok on my pages. Which certificate problem on my localhost was mentioned there ? I run it under docker.

Under my OS kubuntu 20 it worked ok, am am sure. The thing is that I installed kubuntu 22 with php 8.2, but this project I need to leave on php 8.1, that why I try to run it under docker...

Did I miss something in docker installation ? Which debugging can I make in this case ?

0 likes
0 replies

Please or to participate in this conversation.