1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-29 04:17:07 +00:00
mailinabox/containers/docker/run.sh
Joshua Tauberer 074b75b6a5 dockerize (work in progress)
Docker support was initially worked on in 2bbb7a5e7e, but it never really worked.

This extends f7d7434012800c3572049af82a501743d4aed583 which was an old branch for docker work.
2015-01-18 14:11:12 -05:00

51 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Use this script to launch Mail-in-a-Box within a docker container.
# ==================================================================
#
# A base image is created first. The base image installs Ubuntu
# packages and pulls in the Mail-in-a-Box source code. This is
# defined in Dockerfile at the root of this repository.
#
# A mailinabox-userdata container is started next. This container
# contains nothing but a shared volume for storing user data.
# It is segregated from the rest of the live system to make backups
# easier.
#
# The mailinabox-services container is started last. It is the
# real thing: it runs the mailinabox image. This container will
# initialize itself and will initialize the mailinabox-userdata
# volume if the volume is new.
DOCKER=docker.io
# Build or rebuild the image.
# Rebuilds are very fast.
$DOCKER build -q -t mailinabox .
# Start the user-data containerw which is merely to create
# a container that maintains a reference to a volume so that
# we can destroy the main container without losing user data.
if ! $DOCKER ps -a | grep mailinabox-userdata > /dev/null; then
echo Starting user-data volume container...
$DOCKER run -d \
--name mailinabox-userdata \
-v /home/user-data \
scratch bash
fi
# End a running container.
if $DOCKER ps -a | grep mailinabox-services > /dev/null; then
echo Deleting container...
$DOCKER rm mailinabox-services
fi
# Start container.
echo Starting new container...
$DOCKER run \
-p 25 -p 53 -p 80 -p 443 -p 587 -p 993 \
--volumes-from mailinabox-userdata \
--name mailinabox-services \
-t -i \
mailinabox