From b385c233b68286de1f52c4df2359d19eb318d6c2 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 3 Feb 2015 13:24:34 -0500 Subject: [PATCH] transition towards multi-container setup with a startup script --- Dockerfile | 1 - docker-run | 2 +- startup | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 startup diff --git a/Dockerfile b/Dockerfile index 78a56dc..8c04c58 100755 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,6 @@ FROM ubuntu:14.04 MAINTAINER Adam Brown "adamarthurryan@gmail.com" - # update package sources # and get some basics RUN apt-get -y update && apt-get -y install \ diff --git a/docker-run b/docker-run index d68afd3..db641d3 100755 --- a/docker-run +++ b/docker-run @@ -1,3 +1,3 @@ #!/bin/bash -docker run -v ~/docker/data:/data -p=8000:8000 -p=9000:9000 -p=3000:3000 -p=35729:35729 -it adamarthurryan/mean-dev \ No newline at end of file +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 \ No newline at end of file diff --git a/startup b/startup new file mode 100755 index 0000000..cec5bc7 --- /dev/null +++ b/startup @@ -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 +