Last active
August 15, 2024 15:15
-
-
Save clintkitson/0f1e4673e0034c5b905e824d944699a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Disable VirtualBox authentication | |
VBoxManage setproperty websrvauthlibrary null | |
// Start SOAP service so REX-Ray can talk to VirtualBox from the container host VMs | |
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv -H 0.0.0.0 -v | |
// Create a Swarm cluster | |
docker-machine create --driver=virtualbox default | |
eval $(docker-machine env default) | |
TOKEN=$(docker run --rm swarm create) | |
docker-machine create --driver=virtualbox --swarm --swarm-master --swarm-discovery token://$TOKEN manager | |
docker-machine create --driver=virtualbox --swarm --swarm-discovery token://$TOKEN agent1 | |
docker-machine create --driver=virtualbox --swarm --swarm-discovery token://$TOKEN agent2 | |
// Install REX-Ray | |
for each in $(echo -e "manager\nagent1\nagent2\n"); do docker-machine ssh $each "curl -sSL https://dl.bintray.com/emccode/rexray/install | sh -s stable" ; done | |
// Make sure to switch out username with your username! Path is volume directory for storing external volumes. | |
for each in $(echo -e "manager\nagent1\nagent2\n"); do docker-machine ssh $each "sudo tee -a /etc/rexray/config.yml << EOF | |
rexray: | |
logLevel: debug | |
storageDrivers: | |
- virtualbox | |
volume: | |
mount: | |
preempt: false | |
virtualbox: | |
endpoint: http://10.0.2.2:18083 | |
tls: false | |
volumePath: /Users/username/VirtualBox Volumes | |
controllerName: SATA | |
" ; done | |
// Start REX-Ray | |
for each in $(echo -e "manager\nagent1\nagent2\n"); do docker-machine ssh $each "sudo rexray start" ; done | |
// Set local Docker instance to use Swarm as endpoint | |
eval $(docker-machine env --swarm manager) | |
// Make sure Swarm is working | |
docker info | |
// Start container with rescheduling | |
docker run -tid -e reschedule:on-node-failure --volume-driver=rexray \ | |
-v postgres1:/var/lib/postgresql/data postgres | |
// Find the host the container is running on (see first part of container name) | |
docker ps | |
// Stop container host | |
docker-machine stop agent1 | |
// Monitor for stop and restart | |
docker ps | |
// Swarm logs can be reviewed for restarts | |
docker-machine ssh manager | |
docker logs swarm-agent-master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment