我创建了一个docker
要运行多个容器的图像。这个 docker 镜像依赖于一些对所有容器都保持不变的东西,但唯一的区别是容器的配置。
version: '2.4'
services:
s1:
image: testdockerimg:latest
volumes:
- /home/andrew/Documents/CVAI/configs/s1config.json:/home/andrew/Documents/CVAI/configs/config.json
- /home/andrew/Documents/CVAI:/home/andrew/Documents/CVAI/
restart: always
mem_limit: 2g
s2:
image: testdockerimg:latest
volumes:
- /home/andrew/Documents/CVAI/configs/s2config.json:/home/andrew/Documents/CVAI/configs/config.json
- /home/andrew/Documents/CVAI:/home/andrew/Documents/CVAI/
restart: always
mem_limit: 2g
在上面的文件中,您可以看到我为容器提供s1config
和,但其余内容保持不变,这就是两个容器的容量相同的原因。因此,docker 在两个容器之间共享容量,因此所有数据都在容器之间混合,而不是分开。s2config
s1
s2
/home/andrew/Documents/CVAI
有什么方法可以分离多个容器之间的卷。?我不想为此创建多个泊坞窗。请帮忙。谢谢
编辑
更新了 docker-compose 文件:
version: '2.4'
services:
s1:
image: testdockerimg:latest
volumes:
- /home/andrew/Documents/s1/configs/s1config.json:/home/andrew/Documents/CVAI/configs/config.json
- /home/andrew/Documents/s1:/home/andrew/Documents/CVAI/
restart: always
mem_limit: 2g
s2:
image: testdockerimg:latest
volumes:
- /home/andrew/Documents/s2/configs/s2config.json:/home/andrew/Documents/CVAI/configs/config.json
- /home/andrew/Documents/s2:/home/andrew/Documents/CVAI/
restart: always
mem_limit: 2g