Dockerfile pulling from a private gitlab.com repository

I have a project on gitlab (gitlab.com/mycompany/myproject) that builds a docker image.
The Dockerfile is very simple:
FROM registry.gitlab.com/othercompany/someproject:1.0.0
In gitlab I have setup a variable DOCKER_AUTH_CONFIG containing the credentials for this othercompany repo.
when building the pipeline in gitlab CI I get an error “repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied”

I can build this project on my local machine but I have to make sure that I am logged into the correct (othercompany) docker repo due to this issue https://github.com/moby/moby/issues/37569 which prevents to be logged into both gitlab repos simultaneously.
I guess that this is the same issue that prevents the build to succeed in gitlab CI.

If I change the FROM to another private repo not on gitlab.com then CI build also works without issue.

Is there any workaround that I can apply on gitlab CI so I can pull the image from the other private gitlab repo?