简体   繁体   中英

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:

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.

When I use docker create this are the credentials I have to use that in the above example are missing:

   --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:

在此处输入图片说明

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:

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:

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. 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. 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. According to the images in your docker-compose file, it will set the registry server URL automated.

One more thing you need to take care of is that all the images in the docker-compose must in the same registry. You can see the limitation here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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