When I started the project I also wanted to have some kind of cache so I don’t need to download every package every time I rebuild the image during the development. Then I left the configuration there even though I am not sure that would work. So yes, I could improve it.
Hi Rimelek, I am Yagna. I am badly stuck on creating an image using a dockerFile with php8.x.
i need dockerfile built on linux image with php8x, apache and mysql.
Below is my docker file. I am trying to run through gitlab CI. Kindly kindly help me to fix this problem. i am ever greatful to you. please help me with the dockerfile, so that i will use it.
You have probably noticed that your shared code was different from what you wanted to share. Please, follow the below guide next time and use code blocks for code snippets.
You are not using the official image. This topic is about the official Docker image for PHP. I share the link again since it was shared years ago: https://hub.docker.com/_/php
The image description shows you how you can add extensions.
With the official image you don’t even need to use apt to install extensions maybe only dependencies of the extensions. If you have a specific problem or please share that with an error message in case you have one and share what you have tried before to solve the problem.
I’m a relative Docker / PHP newbie, and having trouble installing the gd extension (using nginx and mariadb). My dockerfile is identical to that recommended here https://hub.docker.com/_/php, but (after running docker compose up) gd does not show up in phpinfo(). I also tried the following:
FROM php:8.2-fpm
RUN docker pull mlocati/php-extension-installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd xdebug
…but still no joy. In case it’s relevant, phpinfo() reports the following Configuration Command:
That must have been failed. When you refer to an image in the COPY instruction, you don’t need to pull it and definitely not using the docker pull command in the Dockerfile. Please, share the Dockerfile based on the official instructions (I know you wrote it’s identical) and the commands you used t build the image and run the container to check the extension. Don’t look for it in the configure command of PHP, because it was not built with the enable-gd flag, it was added as an extension. Let’s say you built your image using this command:
docker build . -t localhost/test
The following commands should reveal if GD is installed or not:
Great question! Adding extensions to your PHP image for your Docker rootless production system is a smart move to enhance functionality. Since you’ll be using PHP 8.1.0-fpm with Nginx, here’s a brief guide to help you out:
Update Dockerfile: Open your Dockerfile and locate the section where PHP extensions are installed. You’ll want to add the necessary lines for each extension you mentioned.
Repeat for Other Extensions: Follow similar steps for the intl, mysqli, pdo_mysql, zip, and opcache extensions. Make sure to adjust the package names and configuration commands accordingly.
Rebuild Image: After updating the Dockerfile, rebuild your image using docker build.
Nginx Configuration: Since you’ll be using Nginx, ensure your Nginx configuration points to your PHP-FPM container correctly.
Test and Verify: Once your image is rebuilt, spin up your containers and test your setup thoroughly to make sure the extensions are working as expected.