def prepare_volume_for_rollback(self, target_version: str, source_volume: str, target_version_image_name: str = None,
                                    source="docker"):
        """
        Adjust the permissions of files or directories inside a Docker volume to be accessible
        by the specific user (vespa) and group (vespa) that the container expects to interact with.

        Args:
            target_version (str): The target version of the container.
            source_volume (str): The name of the source Docker volume.
            target_version_image_name (str): The name of the Docker image for the target version.
            source (str): The source to pull the image from ('docker' for Docker Hub or 'ECR').
        """
        self.logger.info(
            f"Preparing volume for rollback with target_version: {target_version}, source_volume: {source_volume}, target_version_image_name: {target_version_image_name}, source: {source}")

        # Determine the image to use
        if source == "docker":
            image_name = f"marqoai/marqo:{target_version}"
        else:
            image_name = target_version_image_name


        try:
            # Pull the image if not already available locally
            self.logger.info(f"Pulling image {image_name}...")
            self.docker_client.images.pull(image_name)
            self.logger.debug(f"Image {image_name} pulled successfully.")

            # Run a container with the provided image and the required command
            self.logger.info(f"Starting container to adjust permissions on volume {source_volume}...")
            container = self.docker_client.containers.run(
                image=image_name,
                name=f"prepare-rollback-{target_version}",
                command=["/bin/sh", "-c", "chown -R vespa:vespa /opt/vespa/var"],  # Using verified shell path
                volumes={source_volume: {'bind': '/opt/vespa/var', 'mode': 'rw'}},
                remove=True,
                detach=False
            )
            self.logger.info(f"Volume {source_volume} prepared successfully for rollback.")
        except APIError as e:
            raise RuntimeError(
                f"Failed to prepare volume {source_volume} for rollback using image {image_name}: {e}") from e

        Adjust the permissions of files or directories inside a Docker volume to be accessible
        by the specific user (vespa) and group (vespa) that the container expects to interact with.

        Args:
            target_version (str): The target version of the container.
            source_volume (str): The name of the source Docker volume.
            target_version_image_name (str): The name of the Docker image for the target version.
            source (str): The source to pull the image from ('docker' for Docker Hub or 'ECR').
        
tests/compatibility_tests/docker_manager.py