Failed upgrade of gitlab mattermost from 16.7.7 to 16.11.0

I am upgrading a single container instance of gitlab mattermost (gitlab-ce docker image from gitlab/gitlab-ce:16.7.7-ce.0 to gitlab/gitlab-ce:16.11.0-ce.0 or any version >=16.8). Gitlab is turned off in the instance (gitlab_rails['enable'] = false in gitlab.rb). If I recreate the container with a newer version I see the following:

Thank you for using GitLab Docker Image!
Current version: gitlab-ce=16.11.0-ce.0

Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
And restart this container to reload settings.
To do it use docker exec:

  docker exec -it gitlab editor /etc/gitlab/gitlab.rb
  docker restart gitlab

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

Cleaning stale PIDs & sockets
It seems you are upgrading from 8.5.8 to 16.11.0.
It is required to upgrade to the latest 16.7.x version first before proceeding.
Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrading-to-a-new-major-version

I have verified that the image version is definitely not 8.5.8, and it is in fact 16.7.7, the latest available, as required in the upgrade paths.

Is there a known workaround?

Solved by setting gitlab_rails['enable'] = true, restarting the image, upgrading the image version, restarting, then finally disabling gitlab rails.