Home > Enterprise >  denied: requested access to the resource is denied - while build and image docker
denied: requested access to the resource is denied - while build and image docker

Time:10-05

My yaml file in github actions:

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      - name: Setup Node.js environment
        uses: actions/[email protected]
        
      - name: Npm install & npm build
        run:  |
            npm install
            npm run build
            
            
      - name: Build & push Docker image
        uses: mr-smithers-excellent/docker-build-push@v5
        with:
          image: changan1111/mydocker
          dockerfile: Dockerfile
          tags: v1, latest
          registry: docker.io
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}  

while build the file, i am getting following error..

Run mr-smithers-excellent/docker-build-push@v5
  with:
    image: changan1111/mydocker
    dockerfile: Dockerfile
    tags: v1, latest
    registry: docker.io
    addLatest: false
    addTimestamp: false
    enableBuildKit: false
  
Docker image name used for this build: docker.io/changan1111/mydocker
Building Docker image docker.io/changan1111/mydocker with tags v1,latest...
Sending build context to Docker daemon  359.8MB

Step 1/6 : FROM node:alpine
alpine: Pulling from library/node
213ec9aee27d: Already exists
a812a649b697: Pulling fs layer
ca485ad162fc: Pulling fs layer
5664861ebdd6: Pulling fs layer
5664861ebdd6: Verifying Checksum
5664861ebdd6: Download complete
ca485ad162fc: Verifying Checksum
ca485ad162fc: Download complete
a812a649b697: Verifying Checksum
a812a649b697: Download complete
a812a649b697: Pull complete
ca485ad162fc: Pull complete
5664861ebdd6: Pull complete
Digest: sha256:7e68e0ab5f106662b4f3a812ebc96548e2fd7880cb8e7d9600de2361ea1eab9a
Status: Downloaded newer image for node:alpine
 ---> 33be9476ddb4
Step 2/6 : WORKDIR '/app'
 ---> Running in 4d42770821e5
Removing intermediate container 4d42770821e5
 ---> 6c0a397a4901
Step 3/6 : COPY package.json .
 ---> 4502a96cb0a3
Step 4/6 : RUN npm install
 ---> Running in 8f1e2aced62e

added 982 packages, and audited 983 packages in 36s

124 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Removing intermediate container 8f1e2aced62e
 ---> 0df727471ebb
Step 5/6 : COPY . .
 ---> 4f873a49ca4a
Step 6/6 : CMD ["npm", "run", "start"]
 ---> Running in d0c52977b926
Removing intermediate container d0c52977b926
 ---> 3447f3108d7b
Successfully built 3447f3108d7b
Successfully tagged changan1111/mydocker:v1
Successfully tagged changan1111/mydocker:latest
Pushing tags v1,latest for Docker image docker.io/changan1111/mydocker...
The push refers to repository [docker.io/changan1111/mydocker]
d5d66d04ff62: Preparing
285dda7fba08: Preparing
d808625591ca: Preparing
e9a85e603ed4: Preparing
6d22cdd7d3fb: Preparing
43ecf4733169: Preparing
fab966db7bfe: Preparing
994393dc58e7: Preparing
fab966db7bfe: Waiting
43ecf4733169: Waiting
994393dc58e7: Waiting
denied: requested access to the resource is denied
Error: Command failed: docker push docker.io/changan1111/mydocker --all-tags

My working copy:

enter image description here

Please help on resolving this issue.

CodePudding user response:

If you check the source code in docker.js you see that you should see a log message: Logging into Docker registry if username and password are declared.

I don't see this in your log so I think the secrets are wrong. Maybe a typo in any of the names? Or maybe any of the 2 is empty?

  • Related