• 欢迎订阅我的Youtube频道
  • 欢迎加入我的电报群

Pass environment variables to Azure container instance

Uncategorized fennng 1年前 (2018-02-12) 1009次浏览 0个评论

In my last post, I created a wordpress on Azure container instance. And I used Azure database for mysql as the database.

The reason I chose to use Azure database is that it’s cheaper than docker container.

But it doesn’t stop you to use a docker container as a database server.

Here is how you can create a mysql server in docker. 

az container create –name tempmysql –image mysql -e MYSQL_ROOT_PASSWORD=yourpassword –resource-group testACI –ip-address public –port 3306 

environment variables and start up command are well supported in  Azure container instance.

[email protected]:~ > az container create -h

Command

    az container create: Create a container group.

Arguments

    –image               [Required]: The container image name.

    –name -n             [Required]: The name of the container group.

    –resource-group -g   [Required]: Name of resource group. You can configure the default group

                                      using `az configure –defaults group=<name>`.

    –command-line                  : The command line to run when the container is started, e.g.

                                      ‘/bin/bash -c myscript.sh’.

    –cpu                           : The required number of CPU cores of the containers.  Default:

                                      1.

    –environment-variables -e      : A list of environment variable for the container. Space

                                      separated values in ‘key=value’ format.

    –ip-address                    : The IP address type of the container group.  Allowed values:

                                      Public.

    –location -l                   : Location. You can configure the default location using `az

                                      configure –defaults location=<location>`.

    –memory                        : The required memory of the containers in GB.  Default: 1.5.

    –os-type                       : The OS type of the containers.  Allowed values: Linux,

                                      Windows.  Default: Linux.

    –ports                         : The ports to open.  Default: [80].

    –restart-policy                : Restart policy for all containers within the container group.

                                      Allowed values: Always, Never, OnFailure.  Default: Always.

Azure File Volume Arguments

    –azure-file-volume-account-key : The storage account access key used to access the Azure File

                                      share.

    –azure-file-volume-account-name: The name of the storage account that contains the Azure File

                                      share.

    –azure-file-volume-mount-path  : The path within the container where the volume should be

                                      mounted. Must not contain colon (:).

    –azure-file-volume-share-name  : The name of the Azure File share to be mounted as a volume.

Image Registry Arguments

    –registry-login-server         : The container image registry login server.

    –registry-password             : The password to log in container image registry server.

    –registry-username             : The username to log in container image registry server.

Global Arguments

    –debug                         : Increase logging verbosity to show all debug logs.

    –help -h                       : Show this help message and exit.

    –output -o                     : Output format.  Allowed values: json, jsonc, table, tsv.

                                      Default: json.

    –query                         : JMESPath query string. See http://jmespath.org/ for more

                                      information and examples.

    –verbose                       : Increase logging verbosity. Use –debug for full debug logs.

Examples

    Create a container in a container group with 1 core and 1Gb of memory.

        az container create -g MyResourceGroup –name myalpine –image alpine:latest –cpu 1

        –memory 1

    Create a container in a container group that runs Windows, with 2 cores and 3.5Gb of memory.

        az container create -g MyResourceGroup –name mywinapp –image winappimage:latest –os-type

        Windows –cpu 2 –memory 3.5

    Create a container in a container group with public IP address and ports.

        az container create -g MyResourceGroup –name myalpine –image alpine:latest –ip-address

        public –ports 80 443

    Create a container in a container group that invokes a script upon start.

        az container create -g MyResourceGroup –name myalpine –image alpine:latest –command-line

        “/bin/sh -c ‘/path to/myscript.sh'”

    Create a container in a container group that runs a command and stop the container afterwards.

        az container create -g MyResourceGroup –name myalpine –image alpine:latest –command-line

        “echo hello” –restart-policy Never

    Create a container in a container group with environment variables.

        az container create -g MyResourceGroup –name myalpine –image alpine:latest -e key1=value1

        key2=value2

    Create a container in a container group using container image from Azure Container Registry.

        az container create -g MyResourceGroup –name myalpine –image

        myAcrRegistry.azurecr.io/alpine:latest –registry-password password

    Create a container in a container group using container image from another private container

    image registry.

        az container create -g MyResourceGroup –name myapp –image myimage:latest –cpu 1 –memory

        1.5 –registry-login-server myregistry.com –registry-username username –registry-password

        password

    Create a container in a container group that mounts an Azure File share as volume.

        az container create -g MyResourceGroup –name myapp –image alpine:latest –command-line

        “cat /mnt/azfile/myfile” –azure-file-volume-share-name myshare –azure-file-volume-account-

        name mystorageaccount –azure-file-volume-account-key mystoragekey –azure-file-volume-

        mount-path /mnt/azfile


峰享技术 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Pass environment variables to Azure container instance
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址