I updated PHP on my VPS to fix some vulnerabilities. Do the containers get that fix too, or do I need to wait for updated images?
Does updating PHP on my VPS also patch my Docker containers?
Answers
Usually no. A container generally runs the PHP executable and libraries from its own image, so updating the host's PHP does not replace them. Check the PHP version and vendor security information for each image that uses it.
Containers do share the host kernel, so they are not quite separate virtual machines. But for the PHP application files, thinking of the container as having its own environment is a useful starting point.
Reply to this answer
For a prebuilt application image, check whether its maintainer has released a rebuild containing the fix. Once it is available, pull the updated image and recreate the container. Just restarting an existing container won't replace its image.
With Compose, docker compose pull followed by docker compose up -d is a common way to do that. Check the image's PHP version afterward, since an updated tag alone doesn't guarantee it includes the particular fix.
Reply to this answer
You don't necessarily have to wait for the application image maintainer. You can build your own image using a patched base image or update PHP in a derived image, provided a suitable patched package is available.
Test it before replacing the production container. PHP version changes or package differences can break extensions and application dependencies. Keep the change in a Dockerfile so you can reproduce it rather than relying on a manual edit inside a running container.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Tivnex+3b:
If the image is pinned to a digest, you'll need to update that reference before pulling the new build.