[英]Volume on Docker Swarm is not persistent?
I just want to create a service on Docker Swarm with NGINX and to make data persistent after docker-machine reboot.我只想用 NGINX 在 Docker Swarm 上创建一个服务,并在 docker-machine 重启后使数据持久化。
I check the manager IP我检查经理IP
docker-machine ip manager
Then I go to the machine然后我去机器
docker-machine ssh manager
Inside a Docker Machine I create a new service:在 Docker Machine 中,我创建了一个新服务:
docker service create -p 80:80 --mount type=volume,target=/usr/share/nginx/html --name nginx nginx
Here I expect to have a service running with NGINX on the port 80 with an unnamed volume.在这里,我希望在端口 80 上有一个与 NGINX 一起运行的服务,并带有一个未命名的卷。
In a web browser I see that NGINX is online at MANAGER_IP:80.在 Web 浏览器中,我看到 NGINX 在 MANAGER_IP:80 在线。
With docker inspect CONTAINER_ID
can find the path to the volume and to modify eg index.html
.使用
docker inspect CONTAINER_ID
可以找到卷的路径并进行修改,例如index.html
。
But after docker-machine stop
and docker-machine start
my change disappears.但是在
docker-machine stop
和docker-machine start
我的更改消失了。
Why?为什么? What do I have to do to make it persistent (to be available after rebooting docker-machine) ?
我该怎么做才能使其持久化(重新启动 docker-machine 后可用)?
Any advice much appreciated.任何建议非常感谢。
can you try this你能试试这个吗
docker service create -p 80:80 --mount type=volume,source=myvolume,destination=/usr/share/nginx/html --name nginx nginx
You just didn't mention the source in your command你只是没有在你的命令中提到来源
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.