简体   繁体   English

将Docker映像从gitlab-ci推送到Azure容器注册表

[英]Pushing Docker image from gitlab-ci to Azure Container Registry

I am familiar with docker in docker (dind) but using along with microsoft/azure-cli image throw docker command not found . 我熟悉docker(dind)中的docker,但未与microsoft/azure-cli image throw docker command not found一起使用。

Here is my setup for gitlab-ci.yml file. 这是我的gitlab-ci.yml文件设置。 I have created Service Principal which is used to authenticate to azure cloud and respective resource group. 我已经创建了Service Principal ,用于对Azure云和相应的资源组进行身份验证。

image: docker:latest

variables:
  PASSWORD: *********
  TENANT_ID: *****-************-*************
  APP_ID: *********-*****-*****
  CLIENT_ID: ****************
  ACR_ID: *******************


stages:
  - build
  - deploy

services:
  - docker:dind

before_script:
  - docker info

build_staging_image:
  stage: build
  image: microsoft/azure-cli
  script:
    - az login --service-principal --username $APP_ID --password $PASSWORD --tenant $TENANT_ID
    - docker build -t azure-vote:latest ./azure-vote
    - docker tag azure-vote votingtestapp.azurecr.io/azure-vote:latest
    - docker push votingtestapp.azurecr.io/azure-vote:latest



deploy:develop:
  stage: deploy
  script:
    - az login --service-principal --username $APP_ID --password $PASSWORD --tenant $TENANT_ID
    - az acr login --name votingTestApp
    - az role assignment create --assignee $CLIENT_ID --role Reader --scope $ACR_ID
    - kubectl apply -f azure-vote-all-in-one-redis.yaml
  only:
    - develop

Any way to fix this error. 任何解决此错误的方法。 I am just trying to create CI/CD pipeline. 我只是试图创建CI / CD管道。

The problem is that microsoft/azure-cli docker image does have docker installed and the docker socket is not mounted onto the container. 问题是microsoft/azure-cli docker映像确实安装了docker,而docker套接字未安装到容器上。 This the docker command will fail. 这将使docker命令失败。

You are using the microsoft/azure-cli just to login to the registery. 您使用microsoft/azure-cli只是用于登录注册表。 But note that you can also login using docker login . 但请注意,您也可以使用docker login Check Log in to a registry . 选中登录到注册表

Therefore, to solve the issue use a dind image and login to azure register using: 因此,要解决此问题,请使用dind图像并使用以下dind登录到天蓝色寄存器:

docker login myregistry.azurecr.io -u xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -p myPassword

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 How do I authenticate using a managed identity from gitlab-ci to push a docker container from gitlab registry to Azure web service? - How do I authenticate using a managed identity from gitlab-ci to push a docker container from gitlab registry to Azure web service? 从Azure容器注册表部署Docker映像 - Deploying a Docker Image from Azure Container Registry 如何从Docker注册表中提取容器映像以部署Azure容器 - How to pull container image from docker registry to deploy azure container 如何从 GitLab 容器注册表将 Docker 容器部署到 Azure 应用服务 - How to deploy a Docker container to Azure App Service from GitLab container registry 将 Gitlab 容器注册表迁移到 Azure 容器注册表 - Migrating Gitlab Container Registry To Azure Contaner Registry Azure ACR 任务无法从 Azure 容器注册表中提取 docker 映像 - Azure ACR task not able to pull the docker image from Azure container registry 如何从 Azure 容器注册表中删除映像 - How to delete image from Azure Container Registry 来自Azure容器注册表的测试图像 - test image from azure container registry 无法从 Azure 容器注册表中提取映像 - Unable to pull image from Azure Container Registry 如何使用 Terraform 从 azure 容器注册表中提取和部署 docker 映像? - How to pull and deploy a docker image from azure container registry using Terraform?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM