Apache-php to include mysqli automatically

Hi

I have installed the below and this works fine.

docker run -d -p 8001:80 --name apache-php -v “/mnt/Backup Drive/www”:/var/www/html php:7.4-apache

but, as the web pages use MySQL, everytime I recrate the docker image i have to log onto the containers SSH and enter

docker-php-ext-install mysqli

Stop the container and start

Then the web page works, is there any way to make docker always install that if the container is recreated?

  1. there is no “container’s SSH”. At least I hope. docker exec just runs a command in the container’s kernel namespaces.
  2. If you really created an image, why don’t you just add the installation of the mysqli extension to the Dockerfile?
  3. If you don’t use Dockerfile, you should: Dockerfile reference | Docker Docs

Never just “commit” a container to save as an image.