添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello,

I’m new to jenkins and i’m struggling since few hours.
Here is my piece of code to push my image to my docker hub

 stage('Build-Push Docker Image') {
            steps {
                script {
                    checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'f485db53-bb94-4b80-8711-6b453106efcc', url: 'https://gitlab.com/GoodMorrrrning/footfront.git']])
                    def dockerfile = 'Dockerfile'
                    def customImage = docker.build("vuejs-foot", "-f ${dockerfile} ./")
                   docker.withRegistry('', 'dockercon'){
                        customImage.push()
and here is the error i get : 
$ docker login -u myemail.com -p ******** https://index.docker.io/v1/
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /var/jenkins_home/workspace/footfront@tmp/3a8d0a39-5be0-4f3e-b7f4-e65e7bebf992/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
+ docker tag vuejs-foot vuejs-foot:latest
+ docker push vuejs-foot:latest
The push refers to repository [docker.io/library/vuejs-foot]
0a49352ca6f5: Preparing
194b12cb5e85: Preparing
2b60bbe779e0: Preparing
4c6a1307a10b: Preparing
bb0903fd6f90: Preparing
9c01e5b3bd66: Preparing
57b608dd7b54: Preparing
36b50b131297: Preparing
9c01e5b3bd66: Waiting
57b608dd7b54: Waiting
36b50b131297: Waiting
denied: requested access to the resource is denied

I cant understand why i have this error because i have succesfully logged in.
I also have tried many variation of this code, for exemple teeling a specific url like : ‘https://index.docker.io/v1/

Thanks for helping :slight_smile:

Hello Thanks for your answer.
Here is a screenshot of my docker hub account i have no image vuejs-foot but i want to push it to my account.

I have à personnal account so the rights are fine i think.

Then you just need to change your tag before pushing to include your Docker Hub handle instead of the default ‘library’.

docker tag vuejs-foot martinmartin234/vuejs-foot
docker push martinmartin234/vuejs-foot

Thanks you :slight_smile:
Cant belive that i struggeled a lot of time for it ):
I share the part of the script i used to fix the issue

stage('Build-push Docker Image') {
            steps {
                script {
                    checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'f485db53-bb94-4b80-8711-6b453106efcc', url: 'https://gitlab.com/GoodMorrrrning/footfront.git']])
                    def dockerfile = 'Dockerfile'
                    def imageTag = "martinmartin234/vuejs-foot" 
                    def customImage = docker.build(imageTag, "-f ${dockerfile} ./")
                    docker.withRegistry('', 'dockercon') {
                        customImage.push()

Merci le s