BitBucketpipe道 – docker未经授权:需要authentication – Docker推送成功login

这个问题适用于Bitbucketstream水线。 我已经看到了其他相关的问题,坦率地说,Bitbucket yaml和Dockerfile脚本在bashterminal中直接执行时效果很好。

就在执行pipe道时,它成功login后就失败了。

这是我的Yaml文件:

# enable Docker for the repository options: docker: true # Start the pipeline pipelines: default: - step: script: # Name the image and create a docker image - docker build -t "my_docker_id/my_app:latest" . - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - docker push my_docker_id/my_app:latest 

我的Dockerfile看起来像这样:

 FROM ubuntu:latest # Install Python and related tools RUN apt-get update && apt-get install -y --no-install-recommends apt-utils RUN apt-get -y upgrade RUN apt-get install -y python3 RUN apt-get install -y python3-pip RUN pip3 install --upgrade pip # Now use Pip to install Flask RUN pip3 install flask # Set the working directory to Ubuntu user home WORKDIR /home/ubuntu # Then copy the website folder to home folder COPY . /home/ubuntu 

dockerlogin成功:

 docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD<1s Login Succeeded 

pipe道失败:

 docker push my_docker_id/my_app:latest 

失败:

+ docker push cbrodock/corpsite:latest The push refers to a repository [docker.io/cbrodock/corpsite] bdca855fbe4a: Preparing d147d767df7b: Preparing f6aad432f761: Preparing 0da658ad5264: Preparing 84e11e4ededf: Preparing 50fd25888dad: Preparing 2cb0a11f65e0: Preparing ad8ba289abb4: Preparing 33f1a94ed7fc: Preparing b27287a6dbce: Preparing 47c2386f248c: Preparing 2be95f0d8a0c: Preparing 2df9b8def18a: Preparing 50fd25888dad: Waiting 47c2386f248c: Waiting 2cb0a11f65e0: Waiting 33f1a94ed7fc: Waiting 2df9b8def18a: Waiting b27287a6dbce: Waiting 2be95f0d8a0c: Waiting ad8ba289abb4: Waiting unauthorized: authentication required

如果我在MacOS的bashterminal中执行相同的确切步骤,它们将执行正常并推送成功。

有任何想法吗?