Skip to content

Commit 95f6476

Browse files
committed
Using docker named volumes
1 parent ac00e70 commit 95f6476

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Quick Start
2727

2828
1. Create a `bitcoind-data` volume to persist the bitcoind blockchain data, should exit immediately. The `bitcoind-data` container will store the blockchain when the node container is recreated (software upgrade, reboot, etc):
2929

30-
docker run --name=bitcoind-data -v /bitcoin busybox chown 1000:1000 /bitcoin
31-
docker run --volumes-from=bitcoind-data --name=bitcoind-node -d \
30+
docker volume create --name=bitcoind-data
31+
docker run -v bitcoind-data:/bitcoin --name=bitcoind-node -d \
3232
-p 8333:8333 \
3333
-p 127.0.0.1:8332:8332 \
3434
kylemanna/bitcoind

bootstrap-host.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ if [ "$distro" = "trusty" -o "$distro" = "ubuntu:14.04" ]; then
3535
fi
3636

3737
# Always clean-up, but fail successfully
38-
docker kill bitcoind-data bitcoind-node 2>/dev/null || true
39-
docker rm bitcoind-data bitcoind-node 2>/dev/null || true
38+
docker kill bitcoind-node 2>/dev/null || true
39+
docker rm bitcoind-node 2>/dev/null || true
4040
stop docker-bitcoind 2>/dev/null || true
4141

4242
# Always pull remote images to avoid caching issues
@@ -45,13 +45,13 @@ if [ -z "${BTC_IMAGE##*/*}" ]; then
4545
fi
4646

4747
# Initialize the data container
48-
docker run --name=bitcoind-data -v /bitcoin busybox chown 1000:1000 /bitcoin
49-
docker run --volumes-from=bitcoind-data --rm $BTC_IMAGE btc_init
48+
docker volume create --name=bitcoind-data
49+
docker run -v bitcoind-data:/bitcoin --rm $BTC_IMAGE btc_init
5050

5151
# Start bitcoind via upstart and docker
5252
curl https://raw.githubusercontent.com/kylemanna/docker-bitcoind/master/upstart.init > /etc/init/docker-bitcoind.conf
5353
start docker-bitcoind
5454

5555
set +ex
5656
echo "Resulting bitcoin.conf:"
57-
docker run --volumes-from=bitcoind-data --rm $BTC_IMAGE cat /bitcoin/.bitcoin/bitcoin.conf
57+
docker run -v bitcoind-data:/bitcoin --rm $BTC_IMAGE cat /bitcoin/.bitcoin/bitcoin.conf

docs/debug.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414

1515
*Note:* This container will be run in the same way as the bitcoind node, but will not connect to already running containers or processes.
1616

17-
docker run --volumes-from=bitcoind-data --rm -it kylemanna/bitcoind bash -l
17+
docker run -v bitcoind-data:/bitcoin --rm -it kylemanna/bitcoind bash -l
18+
19+
You can also attach bash into running container to debug running bitcoind
20+
21+
docker exec -it bitcoind-node bash -l
22+
23+

init/docker-bitcoind.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ExecStartPre=-/usr/bin/docker rm -f $NAME
2525
ExecStartPre=-/usr/bin/docker pull $IMG
2626

2727
# Main process
28-
ExecStart=/usr/bin/docker run --rm --volumes-from ${DATA_VOL} --name ${NAME} -p ${PORT} ${IMG} btc_oneshot $ARGS
28+
ExecStart=/usr/bin/docker run --rm -v ${DATA_VOL}:/bitcoin --name ${NAME} -p ${PORT} ${IMG} btc_oneshot $ARGS
2929

3030
[Install]
3131
WantedBy=multi-user.target

init/upstart.init

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ pre-start script
1111
docker pull kylemanna/bitcoind || true
1212
end script
1313
script
14-
exec docker run --rm --volumes-from=bitcoind-data --name=bitcoind-node --rm -p 8333:8333 -p 127.0.0.1:8332:8332 kylemanna/bitcoind
14+
exec docker run --rm -v bitcoind-data:/bitcoin --name=bitcoind-node --rm -p 8333:8333 -p 127.0.0.1:8332:8332 kylemanna/bitcoind
1515
end script

0 commit comments

Comments
 (0)