From ff5c89034ea4a2090f3e2d8862e3ac590f7bf30b Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 17 Nov 2026 16:01:31 +0530 Subject: [PATCH 1/2] fix(service): record the image tag a recreated global service runs The image migration keeps the old tag in options for a global service it left stopped, because the container still runs that image. `ee service enable` and `ee service refresh` then move the service to the compose file's new tag but left the row at the old one. The running container hides that until the service is stopped again; the next upgrade then sees an updated image, and prunes images, although nothing changed. After init_global_container() and nginx_proxy_check() bring a service up, and after each `up -d` in refresh, read the image the container runs and write its tag to the image's existing options row. Nothing is written when there is no row, when the container runs another image, or when the inspect fails. --- src/Service_Command.php | 1 + src/helper/service-utils.php | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/Service_Command.php b/src/Service_Command.php index bf885b3..2f21b5f 100644 --- a/src/Service_Command.php +++ b/src/Service_Command.php @@ -115,6 +115,7 @@ public function refresh( $args, $assoc_args ) { foreach ( $running_services as $service ) { if ( ! empty( $service['state'] ) ) { EE::exec( \EE_DOCKER::docker_compose_with_custom() . " up -d global-${service['name']}", true, true ); + \EE\Service\Utils\record_global_image_version( 'services_global-' . $service['name'] . '_1' ); } } diff --git a/src/helper/service-utils.php b/src/helper/service-utils.php index 9ab5512..425bfd4 100644 --- a/src/helper/service-utils.php +++ b/src/helper/service-utils.php @@ -51,6 +51,7 @@ function nginx_proxy_check() { if ( ! \EE_DOCKER::docker_compose_up( EE_SERVICE_DIR . '', [ 'global-nginx-proxy' ] ) ) { EE::error( "There was some error in starting $proxy_type container. Please check logs." ); } + record_global_image_version( $proxy_type ); $certs_dir = EE_ROOT_DIR . '/services/nginx-proxy/certs'; $key_path = $certs_dir . '/default.key'; @@ -105,12 +106,40 @@ function init_global_container( $service, $container = '', $recreate = false ) { } else { \EE_DOCKER::boot_container( $container, $up ); } + record_global_image_version( $container ); return true; } else { return false; } } +/** + * Records the tag a global service container runs in its image's `options` row, which the image migration reads. + * `up -d` can move a stopped service to the compose file's new tag, which the migration left unrecorded. + * + * @param string $container Global container name. + */ +function record_global_image_version( $container ) { + + $image = array_search( $container, EE\Migration\GlobalContainers::get_all_global_images_with_service_name(), true ); + $recorded = false === $image ? false : Option::get( $image ); + if ( false === $recorded ) { + return; + } + + $launch = EE::launch( sprintf( "docker inspect --format '{{.Config.Image}}' %s", escapeshellarg( $container ) ) ); + $running = trim( $launch->stdout ); + // A custom compose file may run another image: then there is nothing to record. + if ( 0 !== $launch->return_code || 0 !== strpos( $running, "$image:" ) ) { + return; + } + + $tag = (string) substr( $running, strlen( $image ) + 1 ); + if ( '' !== $tag && $recorded !== $tag ) { + Option::set( $image, $tag ); + } +} + /** * Ensures that frontend and backend networks are initialized. * From 96106513b88e549b13cc4fdef30107579d6bc2dc Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Tue, 17 Nov 2026 20:30:09 +0530 Subject: [PATCH 2/2] fix(service): record only the tag of a digest-pinned image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a global service runs an image referenced by tag and digest (easyengine/x:v1@sha256:…), the value written to the image's options row included the digest, so it no longer matched the tag in img-versions.json. Only the tag, the part before the @, is now recorded. --- src/helper/service-utils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helper/service-utils.php b/src/helper/service-utils.php index 425bfd4..a5b6b2e 100644 --- a/src/helper/service-utils.php +++ b/src/helper/service-utils.php @@ -134,7 +134,8 @@ function record_global_image_version( $container ) { return; } - $tag = (string) substr( $running, strlen( $image ) + 1 ); + // A `tag@digest` reference records only the tag. + $tag = explode( '@', (string) substr( $running, strlen( $image ) + 1 ), 2 )[0]; if ( '' !== $tag && $recorded !== $tag ) { Option::set( $image, $tag ); }