How to update PHP docker container with docker-compose
lets say php has release a security patch and you want to apply that to your docker container. you can follow this instructions to update your php container without any downtime.
first of all you have make sure that your php version in the docker file or in the docker compose file is set to the version that you want. for example if you have
php:7.3.22-fpm and you want to upgrade to the version 7.3.25 you should change the version in docker file or docker-compose file to
need to rebuild your php image(Note that there is no need to run the
docker-compose down or anything else to stop the containers) :
docker-compose build --no-cache --pull YOUR_PHP_CONTAINER_NAME_GOES_HERE
and then you need to bring up the new image:
docker-compose up -d
it will automatically brings the new image up.
I think this method can be applied on most of official images and not just on php.
if any improvements can be applied to this instructions let me know in the comments section.