Unable to run Docker in gitlab access issue is shown

The docker is not running the code is as given:

Docker file is :

FROM ngnix:alpine
copy ./public /usr/share/nginx/html


- build
- package
image: postman/newman
stage: build
- echo “Hello Docker” > index.html

build docker image:
image: docker
stage: package
- docker:dind
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build -t $CI_REGISTRY_IMAGE .
- docker image ls
- docker push --all-tags $CI_REGISTRY_IMAGE

shows error on run as :

ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

The $CI_REGISTRY_IMAGE variable holds the address of the project’s Container Registry, but your build target should be the name of the image itself.

I usually do something like this for feature branches:

    before_script: &docker-login
        - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
        - docker build -f path/to/Dockerfile --target app -t "$CI_REGISTRY_IMAGE/myapp:$CI_COMMIT_REF_SLUG" .
        - docker push "$CI_REGISTRY_IMAGE/myapp:$CI_COMMIT_REF_SLUG"

So that each of my feature branches builds an image with a different tag. Then I use a different image tag on the default branch. YMMV, of course.

This docs page gives more details and some example configs.