transition towards multi-container setup with a startup script

This commit is contained in:
Adam Brown 2015-02-03 13:24:34 -05:00
parent cb85cb7875
commit b385c233b6
3 changed files with 60 additions and 2 deletions

View File

@ -3,7 +3,6 @@ FROM ubuntu:14.04
MAINTAINER Adam Brown "adamarthurryan@gmail.com" MAINTAINER Adam Brown "adamarthurryan@gmail.com"
# update package sources # update package sources
# and get some basics # and get some basics
RUN apt-get -y update && apt-get -y install \ RUN apt-get -y update && apt-get -y install \

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
docker run -v ~/docker/data:/data -p=8000:8000 -p=9000:9000 -p=3000:3000 -p=35729:35729 -it adamarthurryan/mean-dev docker run --name mean-dev -v ~/docker/data:/data --link=mongodb:mongodb -p=8000:8000 -p=9000:9000 -p=3000:3000 -p=35729:35729 -it adamarthurryan/mean-dev

59
startup Executable file
View File

@ -0,0 +1,59 @@
#! /bin/bash
echo "* this script must be run as super user"
# Start a data container, an ssh server, a mongodb instance and a samba server
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 busybox
docker create -v /data/db --name data-db busybox 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 restart automatically on boot and will use the data-db container as a volume
docker run -p 27017 --restart=always --name=mongodb --volumes-from=data-db -d mongo
fi
echo
# test if the data-files container has been created
if docker inspect -f {{.Name}} data-files
then
echo "* data-files exists"
else
echo "* creating data-files"
# The data container has a volume at /data/db, is named 'data' and is based on busybox
docker create -v /data --name data-files busybox echo "Data container - files"
# To connect a client to this server we would:
# sudo docker run --link=mongodb:mongodb -i mongo mongo --host mongodb
fi
# create the samba server
echo "* creating samba server"
sudo docker run --rm -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba data-files