Используя конвейер GitLab, я пытаюсь создать приложение Python с помощью Docker, а затем отправить его образ на Docker Hub, но получил
отказано: запрошенный доступ к ресурсу запрещен
несмотря на успешную регистрацию.
Мои файлы
example1.py Мое Python приложение
.gitlab-ci.yml Файл определения моего конвейера
Dockerfile My DockerFile
Мои переменные
Вот переменные, которые я установил в GitLab, настройки, CI / CD, переменные с использованием переменных среды и их значения:
CI_REGISTRY index. docker .io
CI_REGISTRY_IMAGE index. docker .io / dockerRepository / name
CI_REGISTRY_PASSWORD Пароль
CI_REGISTRY_USER Имя пользователя
Файл определения конвейера
---
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"
Dockerfile
From python:3
ADD example1.py /
CMD ["python3", "./example1.py"
док Репозиторий rHub создается до запуска кода и является частным.
Git Вывод лабораторного конвейера
$ 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