如何为包含卷的 Azure 容器注册表部署简单的多容器应用程序?
How to deploy simple multi-container app for Azure Container Registry containing Volumes?
我想将一个简单的多容器应用程序部署到 Azure 容器注册表。我面临的问题是,
- ACR 要我从 Azure 存储帐户装载卷 >> 文件共享
- 要使用它来安装卷,我的
docker-compose.yml
(见下文)需要提及 azure_file
作为 Docker tutorial 提到的驱动程序。
- 我不确定如何在 Windows 上安装
azure_file
驱动程序,并且 repo 本身自 2018 年以来已存档,不建议使用它。他们正在指导使用docker/cloudstor
,我找不到教程或安装。
- 我无法在本地构建映像并推送到 ACR,因为缺少
azure_file
驱动程序的安装。
在这种情况下我有什么选择?我正在关注官方 Azure tutorial 将我的图像推送到 ACR。
docker-compose.yml
version: "3.7"
services:
web:
build: .
image: flask-app
container_name: flask-app
ports:
- "5000:5000"
volumes:
- code:/code
depends_on:
- redis
redis:
image: redis
volumes:
code:
driver: azure_file
driver_opts:
share_name: myacishare
storage_account_name: mystorageaccount
Dockerfile
FROM python:3.8
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.py
app.py
from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host="redis", port=6379)
@app.route("/")
def hello():
redis.incr("hits")
return "This Compose/Flask demo has been viewed %s time(s)." % redis.get("hits")
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
requirements.txt
flask
redis
您不需要为 Azure 文件共享安装驱动程序。您只需按照步骤为 Windows 安装 Docker 桌面时所示设置 azure_file。它将在资源组中为您创建存储文件共享。
并且如果您使用ACR来存储您的自定义图像,那么您需要像这样登录ACR:
docker login myacr.azurecr.io -u xxxx -p xxxxx
您最好使用登录 ACR 上下文时使用的相同 Azure 帐户。请注意,您需要为该帐户分配足够的 ACR 权限。例如,AcrPull
角色。
我想将一个简单的多容器应用程序部署到 Azure 容器注册表。我面临的问题是,
- ACR 要我从 Azure 存储帐户装载卷 >> 文件共享
- 要使用它来安装卷,我的
docker-compose.yml
(见下文)需要提及azure_file
作为 Docker tutorial 提到的驱动程序。 - 我不确定如何在 Windows 上安装
azure_file
驱动程序,并且 repo 本身自 2018 年以来已存档,不建议使用它。他们正在指导使用docker/cloudstor
,我找不到教程或安装。 - 我无法在本地构建映像并推送到 ACR,因为缺少
azure_file
驱动程序的安装。
在这种情况下我有什么选择?我正在关注官方 Azure tutorial 将我的图像推送到 ACR。
docker-compose.yml
version: "3.7"
services:
web:
build: .
image: flask-app
container_name: flask-app
ports:
- "5000:5000"
volumes:
- code:/code
depends_on:
- redis
redis:
image: redis
volumes:
code:
driver: azure_file
driver_opts:
share_name: myacishare
storage_account_name: mystorageaccount
Dockerfile
FROM python:3.8
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.py
app.py
from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host="redis", port=6379)
@app.route("/")
def hello():
redis.incr("hits")
return "This Compose/Flask demo has been viewed %s time(s)." % redis.get("hits")
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
requirements.txt
flask
redis
您不需要为 Azure 文件共享安装驱动程序。您只需按照步骤为 Windows 安装 Docker 桌面时所示设置 azure_file。它将在资源组中为您创建存储文件共享。
并且如果您使用ACR来存储您的自定义图像,那么您需要像这样登录ACR:
docker login myacr.azurecr.io -u xxxx -p xxxxx
您最好使用登录 ACR 上下文时使用的相同 Azure 帐户。请注意,您需要为该帐户分配足够的 ACR 权限。例如,AcrPull
角色。