Docker container for Magnet Wallet / Masternode.Hi, I am creating basic Dockerfiles to build and host wallets / masternodes.
Why?
With this containers you are able to have multiple wallets / masternodes on the same VPS.
Each container runs in its own environment and does not effect any services on the host system or other containers.
People running multiple masternodes rent for each a VPS, with this you can have multiple masternodes on the same VPS.
Read up on Docker @
https://www.docker.com/what-container if you interrested.
I will guide you through a basic installation on a Ubuntu 17.10 OS.
We will create a docker image with Alpine Linux as base and compile the latest Advance Protocol daemon on it.
Login (ssh) into your VPS:
# Lets upgrade all packages.
> apt-get update
> apt-get upgrade -y
# If you are on a VPS with low RAM and no swap space, lets create one
> fallocate -l 2G /swapfile
> chmod 600 /swapfile
> mkswap /swapfile
> swapon /swapfile
> cp /etc/fstab /etc/fstab.bak
> echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Install Docker
> apt-get install apt-transport-https ca-certificates curl software-properties-common -y
> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
> apt-key fingerprint 0EBFCD88
> add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"
> apt-get update
> apt-get install docker-ce -y
# Create a directory and copy paste the the content into the Dockerfile
> mkdir -p magnetBuild
> cd magnetBuild
> nano Dockerfile
# save the file: CLTR+X
# Dockerfile for magnetd on alpine linux
# http://magnetwork.io/
FROM alpine
LABEL version="1.2-61401-dockerMagnetd"
LABEL description="Dockerized magnetd daemon"
LABEL maintainer="TEmp"
# libboost >1.37 need suffix "-mt"
ARG BOOST_LIB_SUFFIX=-mt
# Install all necessary packages
RUN apk --no-cache --update add nano libstdc++ libtool build-base git autoconf automake linux-headers boost-dev openssl-dev db-dev miniupnpc-dev gmp-dev
# clone the magnet git and compile it, copy to /usr/bin and delete it afterwards
RUN mkdir -p magnetSource && \
cd magnetSource && \
git clone https://github.com/magnetwork/magnet.git . && \
chmod +x compile.sh && \
./compile.sh && \
cp /magnetSource/src/magnetd /usr/bin && \
cd .. && \
rm -rf /magnetSource
# here comes the APK clean up
RUN apk del build-base git autoconf automake libtool linux-headers && \
rm -rvf /var/cache/apk/*
# Create the image, this will take some time!
> docker build -t magnetd .
# After the image is created, start it with an interactive shell inside
# You can repeat this step and create multiple containers now, make sure to use different ports & names
# -it = interactive
# -p = map ports from host to container
# --name = give the container a name
> docker run -it -p 17177:17177 --name MAG01 magnetd
# Inside of the docker container, we will start the magnetd daemon for the first time
# the daemon will exit again after creating the datadir, just wait a sec.
>> magnetd &
# Now cd into the dataDirectory and edit the config file, eg.: port, rpc information, masternode settings, ....
# we also download the bootstrap and unzip it here
>> cd ~/.magnet/
>> wget http://magnetwork.io/Wallets/bootstrap.zip && unzip bootstrap.zip && rm bootstrap.zip
>> nano magnet.conf
rpcallowip=127.0.0.1
rpcport=17179
rpcuser=INSERT_YOUR_USERNAME
rpcpassword=INSERT_YOUR_PASSWORD
server=1
daemon=1
listen=1
staking=1
port=17177
debug=all
addnode=35.195.167.40:17177
addnode=35.199.188.194:17177
addnode=104.196.155.39:17177
addnode=35.197.228.109:17177
addnode=35.198.35.45:17177
addnode=35.197.145.93:17177
addnode=35.199.1.114:17177
addnode=35.201.4.254:17177
addnode=35.188.240.39:17177
addnode=35.199.48.8:17177
addnode=146.148.79.31:17177
addnode=104.196.202.240:17177
addnode=35.195.122.245:17177
addnode=35.198.82.29:17177
addnode=35.200.247.198:17177
# Lets restart the daemon now
>> magnetd
# Verify its running
>> ps -ef
# Check the debug.log
>> tail -f debug.log
# DETACH the container
# press CLTR+P+Q
# SOME USEFUL DOCKER COMMANDS
# Verfiy the container is running on the host system
> docker ps -a
# Stats of all your containers
> docker stats
# Start / Stop containers
> docker start <containername>
> docker stop <containername>
# Execute a command inside of your container and exit again
> docker exec <containername> ps -ef
# Spawn a shell inside of the container
> docker exec -it <containername> /bin/sh
# Attach to a container
> docker attach <containername>
Thats it for now, hope this helps some of you who want to run multiple / sandboxed wallets on the same machine.
Ofc, you can do more with docker images
+ make the start full automatic
+ restart in case daemon crashes
+ send emails on events
+ basically limit is what you imagine!!
I build docker images for other coins as well. For questions, you can find me in the discord channel.
If you found this useful buy me a coffee =)
MAG: Mj46rMwE9LfNUDFLBy2TVb5Q85r15aVdQz
BTC: 1P1vR2T3kpJHXdWoMbiXq18moqGjGoz7Kz