Docker Compose v2如何使卷永久使用 [英] How to make volumes permanent with Docker Compose v2

查看:140
本文介绍了Docker Compose v2如何使卷永久使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道其他人也有类似的问题,但是使用v2的文件格式,我没有找到任何东西。



我想制作一个非常简单的测试应用程序来与MemSQL一起玩,但是在 docker-compose down 之后,我无法获取卷。如果我明白了Docker Docs的权限,那么在不明确说明的情况下,不应删除卷。一切似乎都适用于 docker-compise up ,但是在下载之后,再次重新启动所有数据从数据库中删除。



这是我的docker-compose.yml:

 版本:'2'
服务:
app:
build:。
链接:
- memsql
memsql:
image:memsql / quickstart
volumes_from:
- memsqldata
ports:
- 3306:3306
- 9000:9000
memsqldata:
image:memsql / quickstart
命令:/ bin / true
卷:
- memsqldatavolume:/ data

卷:
memsqldatavolume:
驱动程序:local


解决方案

这是追溯到MemSQL的一个坏文档。 memsql / quickstart 中的MemSQL数据路径是 / memsql 而不是 / var / lib / memsql 像一个独立的安装(和MemSQL文档),而且绝对不会像某人告诉我的 / data


I realize other people have had similar questions but this uses v2 compose file format and I didn't find anything for that.

I want to make a very simple test app to play around with MemSQL but I can't get volumes to not get deleted after docker-compose down. If I've understood Docker Docs right, volumes shouldn't be deleted without explicitly telling it to. Everything seems to work with docker-compose up but after going down and then up again all data gets deleted from the database.

As recommended as a good practice, I'm using separate memsqldata service as a separate data layer.

Here's my docker-compose.yml:

version: '2'
services:
    app:
        build: .
        links:
            - memsql
    memsql:
        image: memsql/quickstart
        volumes_from:
            - memsqldata
        ports:
            - "3306:3306"
            - "9000:9000"
    memsqldata:
        image: memsql/quickstart
        command: /bin/true
        volumes:
            - memsqldatavolume:/data

volumes:
    memsqldatavolume:
        driver: local

解决方案

This was traced back to a bad documentation from MemSQL. MemSQL data path in memsql/quickstart container is /memsql and not /var/lib/memsql like in a stand-alone installation (and in MemSQL docs), and definitely not /data like somebody told me.

这篇关于Docker Compose v2如何使卷永久使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆