[英]Issue with docker swarm and named volumes
I'm having some issues using named volumes in one of my docker stacks. 我在我的一个Docker堆栈中使用命名卷时遇到一些问题。
Basically I'm running a bitcoin node developed by bcoin. 基本上,我正在运行由bcoin开发的比特币节点。 What I'm trying to achieve is to have the containers running the nodes to write and read the blockchain data from a Digital Ocean volume attached to one of my droplets (VMs).
我要实现的目标是让运行节点的容器从附着到我的一个液滴(VM)上的Digital Ocean卷中写入和读取区块链数据。 I'm guessing I'm having some issues because I normally use volumes one way only, having stuff in my host machine being present in my containers.
我猜我遇到了一些问题,因为我通常仅以一种方式使用卷,因为主机中的内容存在于容器中。
This DO volume is present in the directory /mnt/blockchain-data
in my manager node (or droplet). 该DO卷存在于我的管理器节点(或Droplet)中的目录
/mnt/blockchain-data
中。
So here's my docker-stack.yml file: 所以这是我的docker-stack.yml文件:
version: "3.6"
services:
bcoin:
image: hollarves/bcoin-mueve
ports:
#-- Mainnet
# - "8333:8333"
# - "8332:8332" # RPC/HTTP
# - "8334:8334" # Wallet
#-- Testnet
- "18333:18333"
- "18332:18332" # RPC/HTTP
- "18334:18334"
networks:
- bitcoin-private-net
volumes:
- blockchain:/data
- ${PWD}/bitcoin/secrets/bcoin.conf:/data/bcoin.conf
- ${PWD}/bitcoin/secrets/wallet.conf:/data/wallet.conf
environment:
BCOIN_CONFIG: /data/bcoin.conf
deploy:
labels:
- "traefik.docker.network=bitcoin-net"
- "traefik.bcoin.frontend.rule=Host:bcoin.xxxx.com"
- "traefik.bcoin.backend=bcoin"
- "traefik.bcoin.port=18332"
- "traefik.bcoin.frontend.entryPoints=http"
- "traefik.bcoin-wallet.frontend.rule=Host:bcoin-wallet.xxxx.com"
- "traefik.bcoin-wallet.backend=bcoin-wallet"
- "traefik.bcoin-wallet.port=18334"
- "traefik.bcoin-wallet.frontend.entryPoints=http"
placement:
constraints:
- node.role == manager
volumes:
blockchain:
driver: local
driver_opts:
type: bind
device: :/mnt/blockchain-data
networks:
bitcoin-private-net:
external: true
So basically I want whatever is in the /data
directory of my containers to be synced with whatever it is in my /mnt/blockchain-data
in my host machine. 因此,基本上,我希望将容器的
/data
目录中的内容与主机中/mnt/blockchain-data
中的内容进行同步。 If the container writes some new blocks they should be copied to the /mnt/blockchain-data
dir, and if a new bitcoin node is replicated, it should already have it's data directory synced with the files in my host machine. 如果容器写入了一些新块,则应将其复制到
/mnt/blockchain-data
目录中,并且如果复制了新的比特币节点,则其数据目录应该已经与主机中的文件同步。
The main idea is to avoid redownloading the blockchain whenever a node is destroyed and recreated for whatever reason. 主要思想是避免由于任何原因破坏和重新创建节点时重新下载区块链。 As well as being able to replicate as many nodes I want without having to download the blockchain for each one of them.
不仅能够复制所需的节点,而且不必为每个节点下载区块链。
Any ideas on what I might be doing wrong? 关于我可能做错了什么的任何想法? Thanks!
谢谢!
There are various ways to achieve your goal, especially in a swarm environnement. 有多种方法可以实现您的目标,尤其是在蜂拥的环境中。 At first, let's say that docker does not sync volumes among swarm, unless you use a suited driver.
首先,假设docker不会在群集之间同步卷,除非您使用合适的驱动程序。 Thus, you'll have to use drivers or other solutions, according to whether you need r/w or only read!
因此,根据您需要读/写还是只读,您必须使用驱动程序或其他解决方案!
Here are a few ideas (not all solutions!) : 这里有一些想法(不是所有的解决方案!):
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.