简体   繁体   English

在 azure 上的 docker compose 文件上指定帐户凭据

[英]Specify account credentials on a docker compose file on azure

I'm creating an app-service from several images following this tutorial :我正在按照本教程从几个图像创建一个应用程序服务:

The example has the following code for the YML file:该示例具有以下 YML 文件代码:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
    db_data:

The isue is that I have the container images on an Azure private registrer and using a file share to mount a volume and I don't find where to put the credentials for that.问题是我在 Azure 私有注册器上拥有容器映像并使用文件共享来挂载卷,但我找不到将凭据放在哪里。

When I use docker create this are the credentials I have to use that in the above example are missing:当我使用 docker create 时,这是我必须在上面的示例中使用的凭据丢失:

   --registry-login-server XXXXXX \
    --registry-password XXXXXX   \
    --registry-username XXXXXX \
    --azure-file-volume-account-name thisisjustatest \
    --azure-file-volume-account-key XXXXXX \
    --azure-file-volume-share-name XXXXXX 

In this other example some of the credentials are added on a later step using the web interface:另一个示例中,一些凭据是在稍后的步骤中使用 Web 界面添加的:

在此处输入图片说明

Which does not makes sense for my use case, since the idea is to automate the process, not adding more manual steps.这对我的用例来说没有意义,因为这个想法是使过程自动化,而不是添加更多的手动步骤。

I also looked in the code from the CLI to create the app:我还查看了 CLI 中的代码来创建应用程序:

https://docs.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-create https://docs.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-create

And I don't see a parameter to send the account credentials.而且我没有看到发送帐户凭据的参数。

EDIT:编辑:

This is the code I'm using now on the docker compose file:这是我现在在 docker compose 文件中使用的代码:

2vecservice:
  image: coreintelligenceservices.azurecr.io/samples/word2vecservice
  container_name: "apibmongodb1"
  registry-login-server: coreintelligenceservices.azurecr.io
  registry-password: 6JZPjl3gx7JrIDaMT7r6y9gI/xBhFYXf
  registry-username: coreintelligenceservices
  ports:
    - "5000:5000"
  restart: always

I does create the app but it doesn't work.我确实创建了该应用程序,但它不起作用。

It's designed by Azure, the credential for the docker registry is set inside the docker-compose file, it's set as the environment variables for the Azure Web App as your link shows.它由 Azure 设计,docker 注册表的凭据设置在 docker-compose 文件中,如链接所示,它被设置为 Azure Web 应用程序的环境变量。 You can see the description here .您可以在此处查看说明。

If you deploy your images in the portal with the docker-compose file, you need to manually to set the environment variables for the registry credential.如果使用 docker-compose 文件在门户中部署映像,则需要手动设置注册表凭据的环境变量。 But when you use the Azure CLI command az webapp create as you reference to, you can add the parameters --docker-registry-server-user and --docker-registry-server-password , this can set the registry credential for you at the creation time.但是当您使用 Azure CLI 命令az webapp create作为您引用时,您可以添加参数--docker-registry-server-user--docker-registry-server-password ,这可以为您设置注册表凭据创建时间。 According to the images in your docker-compose file, it will set the registry server URL automated.根据您的 docker-compose 文件中的图像,它将自动设置注册服务器 URL。

One more thing you need to take care of is that all the images in the docker-compose must in the same registry.您需要注意的另一件事是 docker-compose 中的所有图像必须在同一个注册表中。 You can see the limitation here .您可以在此处查看限制。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM