dubdiff/docker/start-mongodb
Adam Brown 3bf6223c92 Add 'docker/' from commit '697f105a275dab12b3cc0200a25b067d1f263e8c'
git-subtree-dir: docker
git-subtree-mainline: f27d91a803
git-subtree-split: 697f105a27
2015-04-17 13:00:37 -04:00

38 lines
966 B
Bash
Executable File

#! /bin/bash
# Start a data container and a mongodb instance
echo
# test if the data-db container has been created
if docker inspect -f {{.Name}} data-db
then
echo "* data-db exists"
else
echo "* creating data-db"
# The data container has a volume at /data/db, is named 'data' and is based on mongo
docker create -v /data/db --name data-db mongo echo "Data container - database"
fi
echo
# test if the mongo db server has been created
if docker inspect -f {{.Name}} mongodb
then
# make sure the server is running
if docker inspect -f {{.State.Running}} mongodb
then
echo "* mongodb exists and is running"
else
echo "* starting mongodb"
docker start mongodb
fi
else
echo "* creating new mongodb server"
# Start a mongo db server as a daemon
# The server will use the data-db container as a volume
docker run -p 27017 --name=mongodb --volumes-from=data-db -d mongo
fi