[SYSTEMS GEEK SERIES] Example bash for "Roll Your Own Docker Platform: Manual"

in #beyondbitcoin8 years ago

Assuming that you've got three bare metal servers somewhere, and that 1-3 means that commands are run via ssh on all three machines:

Note: clusterssh is a really great tool for doing exactly this while typing the commands just once.

apt-get install clusterssh
cssh root@server1 root@server2 root@server3

If you've installed cssh, you now have three windows and one text entry field. You can type into the individual windows when you want to address just one host, and into the text entry field when you want to address all three.

Manual Cluster:

1-3: wget get.docker.com
1-3: sh index.html
1-3: sudo curl -L git.io/weave -o /usr/local/bin/weave
1-3: sudo chmod +x /usr/local/bin/weave
1: weave launch
2: weave launch ipaddress_of_1
3: weave launch ipaddress_of_1 ipaddress_of_2
1-3: weave expose
1-3: ip addr #this is used to verify that you now have a new IP address on each machine
1: mkdir caddyfile
1: cd caddyfile
1: touch Caddyfile
2: docker run -d -P ghost | weave attach #note the IP address
2: docker ps #note the port that ghost is being forwarded to.  The -P in the above command enabled automatic port assignment. 
1: nano Caddyfile #I usually leave the Caddyfile in /root until I make the server production-ified, when I move the Caddyfile to a folder owned by the user caddy and I launch Caddy with Systemd
1: docker run -d \
    -v $(pwd)/Caddyfile:/etc/Caddyfile \
    -v $HOME/.caddy:/home/caddy/.caddy \    #note: your ssl certs (yes, automatic, yes, free) will be saved here)
    -p 80:80 -p 443:443 \
    abiosoft/caddy

NOTE 2: Weave is an incredible virtual networking tool.

This means that if you install it on your own PC, you will be able to visit the output of weave attach (a containter IP address) directly from your browser. Like all great things, this is no longer a linux-only affair and should work under both the mac and windows versions of docker. It also means that you can use it to network more than just docker containers-- give it a try :). You can accomplish some pretty incredible network feats with Weave.

Sample Caddyfile:

blog.jacobgadikian.com
gzip
proxy / 10.32.0.4:4567

That was a hell of a lot more typing than I'd anticipated! So, I'm going to check out for now. Supposedly there's a way to get weave to manage the virtual hosting, too: I just haven't figured it out yet and I like Caddy's automated https. Yes, https. Yes, automated.


If you like what I'm writing please do follow @faddat :).

If you like what I'm writing, please know that it's been made possible by @officialfuzzy

If you want to participate in the best discussions on cryptocurrency, please tune in to the next beyondbitcoin show, Fridays at 9AM Central Time.

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 60007.10
ETH 2415.95
USDT 1.00
SBD 2.41