Created
February 10, 2017 07:41
-
-
Save ball6847/9b1c8f6ea452a7ba7c33c36a1e8f9f16 to your computer and use it in GitHub Desktop.
Shell script setup docker volume upon system start
This file contains 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
#!/bin/bash | |
# save this script to setup-docker-volume.sh and chmod to allow executable (chmod +x setup-docker-volume.sh) | |
# Then add this entry to your crontab (generally at /var/spool/cron/root, /etc/cron.d, /etc/crontab) | |
# @reboot /path/to/setup-docker-volume.sh | |
set -e | |
wait_block() { | |
printf . | |
sleep 1 | |
} | |
# --------------------------------- | |
echo | |
printf "waiting for docker to be up and running." | |
until docker version > /dev/null 2>&1; do wait_block; done | |
# --------------------------------- | |
echo | |
printf "waiting for docker-volume-glusterfs to be up and running." | |
until ps aux | grep -q '[d]ocker-volume-glusterfs'; do wait_block; done | |
# --------------------------------- | |
docker run --rm --volume-driver glusterfs --volume uploads:/data alpine sh -c "exit" | |
docker run --rm --volume-driver glusterfs --volume public_upload:/data alpine sh -c "exit" | |
docker start nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment