如何从 GitLab 容器注册表将 Docker 容器部署到 Azure App Service
How to deploy a Docker container to Azure App Service from GitLab container registry
我在 GitLab 上托管了一个应用程序,并设置了 GitLab CI 来构建我的 docker 图像并将其推送到 GitLab 容器注册表中。现在我想在不使用 Azure 容器注册表的情况下将该容器映像部署到 Azure 应用服务中(我不想有另一个注册表)。这可能吗?如何实现?
谢谢
编辑:
我这样试过,但没有用。
出现此错误:
2020-05-27T14:31:32.739Z INFO - Pulling image: project1_administration:latest
2020-05-27T14:31:33.098Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://registry-1.docker.io/v2/library/project1_administration/manifests/latest: unauthorized: incorrect username or password"}
2020-05-27T14:31:33.099Z ERROR - Pulling docker image project1_administration:latest failed:
2020-05-27T14:31:33.100Z INFO - Pulling image from Docker hub: library/project1_administration:latest
2020-05-27T14:31:33.577Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for project1_administration, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2020-05-27T14:31:33.580Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2020-05-27T14:31:33.586Z INFO - Stopping site project1test because it failed during startup.
当我连接到 gitlab 站点时,我使用的用户名和密码有效。它似乎正在尝试使用 Docker hub 来拉取图像而不是 GitLab。
你可以这样做,你需要在appservice中选择private container registry,然后传递凭据
确保您传递的是映像注册表的全名registry.gitlab.com//
假设你的镜像已经在 GitLab 的 Container Registry 中:
- 要从 Azure 访问您的 GitLab 注册表映像,您需要做的第一件事是创建部署令牌(在“设置”->“存储库”下)。复制用户名和密码(您将无法再次访问密码)。确保令牌具有
read_registry
范围。
- 在 Azure 中,为容器创建一个 Web 应用程序。在 Docker 选项卡下,选择 Private Registry。
- 设置选项如下:
- 服务器URL:
https://registry.gitlab.com
- 用户名:从步骤 1 中的 Deploy Token 复制的用户名
- 密码:从步骤 1 中的部署令牌复制的密码
- 图片和标签:
registry.gitlab.com/<username>/<repo>:latest
我在 GitLab 上托管了一个应用程序,并设置了 GitLab CI 来构建我的 docker 图像并将其推送到 GitLab 容器注册表中。现在我想在不使用 Azure 容器注册表的情况下将该容器映像部署到 Azure 应用服务中(我不想有另一个注册表)。这可能吗?如何实现?
谢谢
编辑:
我这样试过,但没有用。
出现此错误:
2020-05-27T14:31:32.739Z INFO - Pulling image: project1_administration:latest
2020-05-27T14:31:33.098Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://registry-1.docker.io/v2/library/project1_administration/manifests/latest: unauthorized: incorrect username or password"}
2020-05-27T14:31:33.099Z ERROR - Pulling docker image project1_administration:latest failed:
2020-05-27T14:31:33.100Z INFO - Pulling image from Docker hub: library/project1_administration:latest
2020-05-27T14:31:33.577Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"pull access denied for project1_administration, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}
2020-05-27T14:31:33.580Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2020-05-27T14:31:33.586Z INFO - Stopping site project1test because it failed during startup.
当我连接到 gitlab 站点时,我使用的用户名和密码有效。它似乎正在尝试使用 Docker hub 来拉取图像而不是 GitLab。
你可以这样做,你需要在appservice中选择private container registry,然后传递凭据
确保您传递的是映像注册表的全名registry.gitlab.com//
假设你的镜像已经在 GitLab 的 Container Registry 中:
- 要从 Azure 访问您的 GitLab 注册表映像,您需要做的第一件事是创建部署令牌(在“设置”->“存储库”下)。复制用户名和密码(您将无法再次访问密码)。确保令牌具有
read_registry
范围。 - 在 Azure 中,为容器创建一个 Web 应用程序。在 Docker 选项卡下,选择 Private Registry。
- 设置选项如下:
- 服务器URL:
https://registry.gitlab.com
- 用户名:从步骤 1 中的 Deploy Token 复制的用户名
- 密码:从步骤 1 中的部署令牌复制的密码
- 图片和标签:
registry.gitlab.com/<username>/<repo>:latest