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
- Clone the repository
- Run
docker-compose -f docker-compose.yml run --rm wordpress_phpunit php -v
Output:
PHP 7.2.10 (cli) (built: Sep 17 2018 09:23:43) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
Usage 2 – Using it in my docker-compose.yml
- My docker-compose.yml
version: "3" services: wordpress_phpunit: image: "chriszarate/wordpress-phpunit"
- Run
Run docker-compose -f docker-compose.yml run --rm wordpress_phpunit php -v
Output:
PHP 7.1.5 (cli) (built: May 13 2017 10:49:18) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.5, Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans
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:
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.The
chriszarate/wordpress-phpunit
docker image was then built. Since it’s based onphpunit-docker/6.0.6
, the generated image had PHP 7.1.5 built into it.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-datephpunit-docker/6.0.6
image, therefore running PHP 7.2.10.
Note that there might be other explanations. This one seems reasonable enough though.