Skip to content
Advertisement

Docker image builds a different version of app

I’m trying to use a docker image and it’s showing a different behavior depending on how I use it.

The image is https://hub.docker.com/r/chriszarate/wordpress-phpunit/

Github is https://github.com/chriszarate/wordpress-phpunit

Usage 1 – Building it locally

  1. Clone the repository
  2. Run docker-compose -f docker-compose.yml run --rm wordpress_phpunit php -v

Output:

JavaScript

Usage 2 – Using it in my docker-compose.yml

  1. My docker-compose.yml
JavaScript
  1. Run Run docker-compose -f docker-compose.yml run --rm wordpress_phpunit php -v

Output:

JavaScript

Notice that the Usage 1 installs PHP 7.2.10 whereas Usage 2 installs PHP 7.1.5

I’ve looked at the Docker hub and it has the latest changes from the git repository.

Am I missing something here?

Advertisement

Answer

So here’s what might have happened:

  1. The phpunit-docker/6.0.6 docker image was initially built and pushed to the docker repository. At that point, PHP 7 was in version 7.1.5, so the Dockerfile built that version into the image.

  2. The chriszarate/wordpress-phpunit docker image was then built. Since it’s based on phpunit-docker/6.0.6, the generated image had PHP 7.1.5 built into it.

  3. Then sometime later, the phpunit-docker/6.0.6 was built and pushed again to the docker repository. Except this time, PHP 7 was in version 7.2.10. That’s definitely odd, and should probably have not happened, though.

So, in this scenario:

  • if you docker pull chriszarate/wordpress-phpunit, you’ll get PHP 7.1.5 as it’s built into its stored image on the docker repository,
  • if you git pull its corresponding project instead, and then build it locally, it’ll be based on the up-to-date phpunit-docker/6.0.6 image, therefore running PHP 7.2.10.

Note that there might be other explanations. This one seems reasonable enough though.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement