gpt4 book ai didi

azure - azure 存储上的 docker-compose 卷 : how to bind to a file

转载 作者:行者123 更新时间:2023-12-02 23:34:30 25 4
gpt4 key购买 nike

我无法访问将 Docker 中的文件链接到我放置在 Azure 存储帐户中的文件的 Azure 容器实例

卷名后面的路径似乎不被接受:/conf/nginx.conf

volumes:
- nginxconf/conf/nginx.conf:/etc/nginx/nginx.conf

这是我的 docker-compose.yml

version: '3.9'

services:
client:
image: nginx
ports:
- '8080:80'
volumes:
- nginxconf/conf/nginx.conf:/etc/nginx/nginx.conf

volumes:
nginxconf:
driver: azure_file
driver_opts:
share_name: nginxfiles
storage_account_name: nginxcontainerstorage
storage_account_key: "xxxxxxxxxxxxxxx"


最佳答案

为了解决我的问题,我修改了 systemctl 服务文件,通过在不同位置指定配置文件来启动 nginx。我有一个包含 nginx.service 的卷,另一个包含我的 nginx 配置。我安装文件夹而不是文件并且它可以工作

我的代码:https://github.com/auriou/dockerfiles/tree/master/nginx

我在本地完成了测试,然后在 azure 上进行了测试

本地:

version: '3.9'

services:
client:
image: nginx
ports:
- '8080:80'
volumes:
- nginxconfig:/etc/nginx/myconfig
- nginxservice:/etc/systemd/system/multi-user.target.wants

volumes:
nginxconfig:
driver: local
driver_opts:
type: none
o: bind
device: "/mnt/c/Users/p.auriou/Documents/GIT/azure/aci/nginx/docker/config"
nginxservice:
driver: local
driver_opts:
type: none
o: bind
device: "/mnt/c/Users/p.auriou/Documents/GIT/azure/aci/nginx/docker/service"

azure :我将文件复制到我的 azure 存储

version: '3.9'

services:
client:
image: nginx
domainname: nginxconf
ports:
- '80:80'
volumes:
- nginxconfig:/etc/nginx/myconfig
- nginxservice:/etc/systemd/system/multi-user.target.wants

volumes:
nginxconfig:
driver: azure_file
driver_opts:
share_name: nginxconfig
storage_account_name: nginxcontainerstorage
storage_account_key: "XXXXXXXXXXX"
nginxservice:
driver: azure_file
driver_opts:
share_name: nginxservice
storage_account_name: nginxcontainerstorage
storage_account_key: "XXXXXXXXXXX"


nginx 的 systemd 文件

[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/myconfig/nginx.conf
ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"

[Install]
WantedBy=multi-user.target

关于azure - azure 存储上的 docker-compose 卷 : how to bind to a file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75675315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com