Azure SQL Edge不会将数据持续到Docker卷

发布于 2025-01-17 11:09:06 字数 982 浏览 0 评论 0原文

我在将数据库数据持久保存到 docker 卷时遇到问题。

我有一个带有 azure SQL Edge 容器的 docker compose。以下是容器的配置:

services:
  azure-sql:
    image: "mcr.microsoft.com/azure-sql-edge"
    hostname: "azure-sql"
    environment:
      ACCEPT_EULA: 1
      MSSQL_SA_PASSWORD: ":8jNZdK7cK"
      MSSQL_USER: "SA"
      MSSQL_PID: "Developer"
    volumes:
      - azure-sql-storage:/var/opt/mssql-extensibility/data
      - azure-sql-storage:/var/opt/mssql-extensibility/log
      - azure-sql-storage:/var/opt/mssql-extensibility
    ports:
      - "1433:1433"

volumes:
  azure-sql-storage:
    external: true

我注意到每次 azure SQL 重新运行容器时,它都会在映射卷中创建新文件夹,而不是使用旧文件夹并在其中存储数据。

在此处输入图像描述

即使容器被废弃,我是否有机会保留数据并重用它?是否可以配置 Azure SQL 容器,以便重用以前创建的目录而不是创建新目录?

我测试了独立容器,但结果是相同的。

我还注意到,如果我停止容器而不是处理它们并重新运行它们 - 数据将被保留。

UPD

看起来这是一个已知问题。 dockerhub 页面上提到了这一点: “在 Docker for Mac 上安装卷不起作用”

I'm having troubles persisting database data to docker volume.

I have a docker compose with azure SQL edge container. Here is the configuration for the container:

services:
  azure-sql:
    image: "mcr.microsoft.com/azure-sql-edge"
    hostname: "azure-sql"
    environment:
      ACCEPT_EULA: 1
      MSSQL_SA_PASSWORD: ":8jNZdK7cK"
      MSSQL_USER: "SA"
      MSSQL_PID: "Developer"
    volumes:
      - azure-sql-storage:/var/opt/mssql-extensibility/data
      - azure-sql-storage:/var/opt/mssql-extensibility/log
      - azure-sql-storage:/var/opt/mssql-extensibility
    ports:
      - "1433:1433"

volumes:
  azure-sql-storage:
    external: true

I noticed that each time azure SQL re-runs a container it creates new folders in the mapped volumes instead of using the old ones and stores data there.

enter image description here

Is there any chance I can persist data and reuse it even when containers are disposed? May Azure SQL container can be configured so reuse previously created directories instead of creating new?

I tested stand alone container but the result was the same.

Also I noticed that if I stop containers instead of disposing them and re-run them – data is persisted.

UPD

Looks like it's a known issue. It's mention on the dockerhub page:
"Mounting a volume does not work on Docker for Mac"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风筝在阴天搁浅。 2025-01-24 11:09:06

不确定关于在Mac上使用卷的已知年龄是多大的,但是我能够。

volumes:
  - azure-sql-storage:/var/opt/mssql

Not sure how old that known-issue about using volumes on a Mac is, but I was able to.

volumes:
  - azure-sql-storage:/var/opt/mssql

Got it from here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文