Cannot push Docker image to Docker Hub from Okteto Deployment Job

Hi

I did a small Java project, which is on Github.

I managed to package it with Maven, build a Docker image and publish it to Docker Hub using Github actions. Now I would like to deploy it to an Okteto environment.

However, when the Okteto deployment job runs, I get this error:

#13 ERROR: server message: insufficient_scope: authorization failed
------
 > exporting to image:
------
error building service 'ideal-octo-tribble': error building image 'foundationer/ideal-octo-tribble:main': You are not authorized to push image 'foundationer/ideal-octo-tribble:main'
 x  Error building service 'ideal-octo-tribble': error building image 'foundationer/ideal-octo-tribble:main': You are not authorized to push image 'foundationer/ideal-octo-tribble:main'
deploy command failed: exit status 1

I don’t understand why this happens. I set the Docker Hub user and token as secrets, both in Github and Okteto. In Github it works fine, but in Okteto it doesn’t.

Also, why it attempts to build the image from scratch instead of downloading it from Docker Hub? I already pushed it to my repo using Github.

This is my first time using Okteto, by the way, so sorry if these questions are too basic.
I would greatly appreciate your help.

Hi @Cardigan7240 and welcome!

This is mostly sure a problem with authentication to dockerhub

Can you explain a bit more what your current setup is? When you say “However, when the Okteto deployment job runs, I get this error:” do you mean you are running okteto deploy locally, or in a github action? Are you using an okteto’s official github action like this one?

Also, are you using cloud.okteto.com? or a private cluster?

Also, why it attempts to build the image from scratch instead of downloading it from Docker Hub? I already pushed it to my repo using Github.

The okteto.yml manifest and the setup would help us understand why. It’s probably a configuration issue, but you’ll likely hit the same auth problems when trying to pull

1 Like

Hi AgustĂ­n

Thanks for reaching out. Let me answer your questions.

I ran the deploy from the Okteto Cloud UI, by clicking on “Launch Dev Environment” and selecting the Github repo. I didn’t use the Github action you mentioned… I should give it a try.

Here are the contents of the okteto.yml file:


build:
  ideal-octo-tribble:
    image: foundationer/ideal-octo-tribble:main
    context: .
deploy:
  - kubectl apply -f k8s.yml
dev:
  ideal-octo-tribble:
    image: okteto/maven:3
    command: bash
    sync:
      - .:/usr/src/app
    forward:
      - 5005:5005
    volumes:
      - /root/.m2

Thanks.

1 Like

@Cardigan7240 thanks for providing your manifest and answering my questions!

The manifest you provided is trying to build and push the image foundationer/ideal-octo-tribble:main

My recommendation while using okteto is to push your images to okteto’s registry. You’ll be able to use these images in your namespace.

For that, your manifest should change to something like

build:
  ideal-octo-tribble:
    image: okteto.dev/ideal-octo-tribble:main
    context: .
deploy:
  - kubectl apply -f k8s.yml
dev:
  ideal-octo-tribble:
    image: okteto/maven:3
    command: bash
    sync:
      - .:/usr/src/app
    forward:
      - 5005:5005
    volumes:
      - /root/.m2

and also replace in your k8s.yml the ocurrences of foundationer/ideal-octo-tribble:main by okteto.dev/ideal-octo-tribble:main (in the case that doesn’t work, try with registry.cloud.okteto.net/<your namespace>/foundationer/ideal-octo-tribble:main)

This should fix your issue :smiley:

Hey AgustĂ­n

I did what you showed me, but now I get a different error:

Error building service 'ideal-octo-tribble': error building image 'registry.cloud.okteto.net/dev-previews-ideal-octo-tribble-foundationer/ideal-octo-tribble:1.0.0': build failed: failed to solve: error writing layer blob: content digest sha256:d1669123f28121211977ed38e663dca1a397c0c001e5386598b96c89b1b1cd51: not found

I tried to do the deploy both from the Okteto Cloud UI and using the Github action you showed me. I got the same error with both deployment methods.

Hello @Cardigan7240 ,

There might be an issue with your cache, so I am curious if you are able to build using the Okteto CLI instead of building through the UI, so that you can get around the cache and potentially get around this issue. You just need to run your build with the command okteto build <your service> --no-cache, and you can find more info here: Okteto CLI | Okteto Documentation

Let us know if that helped!
-Jona

Hi Jona

That solved the issue. I built the project from the CLI using the --no-cache option. It finished without errors. Then I went to the UI, spun up the environment and started right away.

Thanks a lot to everyone for your help!

1 Like