使用GitLabPipeline,我试图由Docker构建一个Python应用程序,然后将其映像发送到DockerHub,但收到错误消息

使用GitLabPipeline,我试图由Docker构建一个Python应用程序,然后将其映像发送到DockerHub,但收到错误消息,gitlab,devops,gitlab-ci,pipeline,Gitlab,Devops,Gitlab Ci,Pipeline,使用GitLab的管道,我试图通过Docker构建一个Python应用程序,然后将其映像发送到Docker Hub,但收到了 拒绝:请求的对资源的访问被拒绝 尽管登录成功 我的档案 example1.py我的Python应用程序 .gitlab ci.yml我的管道定义文件 Dockerfile我的Dockerfile 我的变量 以下是我在GitLab中设置的变量、设置、CI/CD、使用环境变量的变量及其值: CI_注册表index.docker.io CI_注册表_图像index.docker

使用GitLab的管道,我试图通过Docker构建一个Python应用程序,然后将其映像发送到Docker Hub,但收到了

拒绝:请求的对资源的访问被拒绝

尽管登录成功

我的档案 example1.py我的Python应用程序

.gitlab ci.yml我的管道定义文件

Dockerfile我的Dockerfile

我的变量 以下是我在GitLab中设置的变量、设置、CI/CD、使用环境变量的变量及其值:

CI_注册表index.docker.io

CI_注册表_图像index.docker.io/dockerRepository/name

CI_注册表_密码密码

CI_注册表_用户用户名

管道定义文件 Dockerfile dockerHub存储库是在运行代码之前创建的,是私有的

Git实验室管道输出
使用标记docker图像时登录的存储库:

docker登录$注册处
docker build-t$CI_注册表/名称:标记。
docker push$CI_注册表/名称:标记
如果docker push仍然失败且访问被拒绝,则可能意味着您对存储库没有足够的权限,例如只读

---
services:
  - docker:19.03.5-dind

stages:
  - static analysis
  - build


flake8:
  # This installs flake8 a tool for Style guide enforcement and run it for
  # checking file named examole1.py.
  # For more information please see here http://flake8.pycqa.org/en/latest/
  stage: static analysis
  image: python:3.7
  script:
    - python3 -m pip install flake8
    - python3 -m flake8 example1.py

pylint:
  # This installs Pylint, a python static code analysis tool looking for
  # programming errors, help enforcing a coding standard and run it for
  # file called example.py.
  # For more information see https://pypi.org/project/pylint/
  stage: static analysis
  image: python:3.7
  # before_script:
  script:
    - pip install pylint
    - pylint example1.py

docker:
  stage: build
  image: docker:19.03.5-dind
  script:
    - docker info
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t dockerRepository/name:tag .
    - docker push dockerRepository/name:tag"                                                             

From python:3
ADD example1.py /
CMD ["python3", "./example1.py"

$ docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
 WARNING! Using --password via the CLI is insecure. Use --password-stdin.
 WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
 Configure a credential helper to remove this warning. See
 https://docs.docker.com/engine/reference/commandline/login/#credentials-store
 Login Succeeded
 $ docker build -t dockerRepository/name:tag .
 Step 1/3 : From python:3
 3: Pulling from library/python
 8f0fdd3eaac0: Pulling fs layer
 d918eaefd9de: Pulling fs layer
 43bf3e3107f5: Pulling fs layer
 27622921edb2: Pulling fs layer
 dcfa0aa1ae2c: Pulling fs layer
 61cf1e8f9385: Pulling fs layer
 6cb6c5f51ace: Pulling fs layer
 6c164355f57f: Pulling fs layer
 dc0bfafc5e93: Pulling fs layer
 27622921edb2: Waiting
 dcfa0aa1ae2c: Waiting
 61cf1e8f9385: Waiting
 6cb6c5f51ace: Waiting
 6c164355f57f: Waiting
 dc0bfafc5e93: Waiting
 d918eaefd9de: Verifying Checksum
 d918eaefd9de: Download complete
 43bf3e3107f5: Verifying Checksum
 43bf3e3107f5: Download complete
 8f0fdd3eaac0: Verifying Checksum
 8f0fdd3eaac0: Download complete
 61cf1e8f9385: Verifying Checksum
 61cf1e8f9385: Download complete
 27622921edb2: Verifying Checksum
 27622921edb2: Download complete
 6c164355f57f: Verifying Checksum
 6c164355f57f: Download complete
 dcfa0aa1ae2c: Verifying Checksum
 dcfa0aa1ae2c: Download complete
 dc0bfafc5e93: Verifying Checksum
 dc0bfafc5e93: Download complete
 6cb6c5f51ace: Verifying Checksum
 6cb6c5f51ace: Download complete
 8f0fdd3eaac0: Pull complete
 d918eaefd9de: Pull complete
 43bf3e3107f5: Pull complete
 27622921edb2: Pull complete
 dcfa0aa1ae2c: Pull complete
 61cf1e8f9385: Pull complete
 6cb6c5f51ace: Pull complete
 6c164355f57f: Pull complete
 dc0bfafc5e93: Pull complete
 Digest: sha256:aa4cf9b0ef27af04cc3c9a745a7189c86c0d20e3a377a530b734412102759915
 Status: Downloaded newer image for python:3
  ---> 9038c75f5336
 Step 2/3 : ADD example1.py /
  ---> 8b00a4db7562
 Step 3/3 : CMD ["python3", "./example1.py"]
  ---> Running in 5f144f54770a
 Removing intermediate container 5f144f54770a
  ---> 6a9464f2c147
 Successfully built 6a9464f2c147
 Successfully tagged dockerRepository/name:tag
 $ docker images
 REPOSITORY                   TAG                 IMAGE ID            CREATED                  SIZE
 repository/name  851f4741            6a9764f2c147        Less than a second ago   933MB
 python                       3                   9083c75f5336        15 hours ago             933MB
 $ docker push "docker.io/repository/name:$tag"
 The push refers to repository [docker.io/dockerRepository/name]
 afb543a82fc1: Preparing
 e3ef3d65ffb2: Preparing
 98db0f6b946f: Preparing
 c664d35d0409: Preparing
 07aa3e497121: Preparing
 f63773c65620: Preparing
 e6d60910d056: Preparing
 b52c1c103fae: Preparing
 6f1c84e6ec59: Preparing
 dd5242c2dc8a: Preparing
 f63773c65620: Waiting
 e6d60910d056: Waiting
 b52c1c103fae: Waiting
 6f1c84e6ec59: Waiting
 dd5242c2dc8a: Waiting
 denied: requested access to the resource is denied
 ERROR: Job failed: exit code 1