Dockerfile pulling from a private repository

I have a project on gitlab ( that builds a docker image.
The Dockerfile is very simple:
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 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 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?