[英]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.