Last active
August 29, 2015 14:02
-
-
Save gear11/9aa141f64e0adb152ca2 to your computer and use it in GitHub Desktop.
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/sh | |
# The current Google container-optimized image starts Docker before this startup | |
# script gets a chance to run, so our mounts may not be set, etc. | |
# Kill the docker agent and containers that have started already. | |
ps -u root -o pid,cmd | grep docker-agent | perl -pe 's/\s*(\d+).*/$1/' | xargs -I {} kill -9 {}; | |
docker ps -q | xargs -I {} docker rm -f {}; | |
# Mount the MongoDB disk, which should have been attached by the instance create command | |
mkdir /mnt/pd1 | |
mount -t ext4 /dev/disk/by-id/google-mongodb-data-1 /mnt/pd1 | |
# Ensure MongoDB has somewhere to write its data, even if the disk is empty | |
mkdir -p /mnt/pd1/mongodb/data/db | |
# Replace the docker-agent with our enhanced version that can use host dirs for volumes | |
git clone https://github.com/gear11/container-agent.git | |
chmod +x container-agent/container_agent/run_containers.py | |
rm /usr/bin/docker-agent | |
ln -s /container-agent/container_agent/run_containers.py /usr/bin/docker-agent | |
# Install the mongodb client on the host, so we can connect to MongoDB in the container once up and running. | |
# See: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | |
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list | |
apt-get update | |
apt-get install mongodb-org-shell | |
# Start the docker agent | |
service docker-gce-agent start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment