mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-22 07:17:05 +00:00
docker: don't start services ourself
* let the base image's system services manager handle it * move our container start script to occur before system services are started
This commit is contained in:
parent
1db0dd3092
commit
e247929386
18
Dockerfile
18
Dockerfile
@ -5,14 +5,10 @@
|
||||
# To build the image:
|
||||
# sudo docker.io build -t box .
|
||||
|
||||
# Run your container the first time with an interactive console so you can
|
||||
# create your first mail account.
|
||||
# sudo docker.io run -i -t box
|
||||
|
||||
# Then run it in the background and expose all of the ports so that the *host* acts as a Mail-in-a-Box:
|
||||
# (the SSH port is only available locally, but other ports are exposed publicly and must be available
|
||||
# otherwise the container won't start)
|
||||
# sudo docker.io run -d -p 22 -p 25:25 -p 53:53/udp -p 443:443 -p 587:587 -p 993:993 box
|
||||
# Run your container.
|
||||
# -i -t: creates an interactive console so you can poke around (CTRL+D will terminate the container)
|
||||
# -p ...: Maps container ports to host ports so that the host begins acting as a Mail-in-a-Box.
|
||||
# sudo docker.io run -i -t -p 22 -p 25:25 -p 53:53/udp -p 443:443 -p 587:587 -p 993:993 box
|
||||
|
||||
###########################################
|
||||
|
||||
@ -43,6 +39,7 @@ ENV PUBLIC_IP 192.168.200.1
|
||||
|
||||
# Docker-specific Mail-in-a-Box configuration.
|
||||
ENV DISABLE_FIREWALL 1
|
||||
ENV NO_RESTART_SERVICES 1
|
||||
|
||||
# Our install will fail if SSH is installed and allows password-based authentication.
|
||||
# The base image already installs openssh-server. Just edit its configuration.
|
||||
@ -59,6 +56,7 @@ RUN cd /usr/local/mailinabox && scripts/start.sh
|
||||
# Configure services for docker.
|
||||
ADD containers/docker /usr/local/mailinabox/containers/docker
|
||||
RUN /usr/local/mailinabox/containers/docker/setup_services.sh
|
||||
RUN ln -s /usr/local/mailinabox/containers/docker/container_start.sh /etc/my_init.d/99-mailinabox.sh
|
||||
|
||||
# How the container is launched.
|
||||
CMD bash /usr/local/mailinabox/containers/docker/container_start.sh
|
||||
# Start bash so we can poke around.
|
||||
CMD ["/sbin/my_init", "--", "bash"]
|
||||
|
@ -15,27 +15,10 @@ if grep "^PUBLIC_IP=192.168.200.1" /etc/mailinabox.conf > /dev/null; then
|
||||
export PUBLIC_HOSTNAME=`host $PUBLIC_IP | sed -e "s/.* //" | sed -e "s/\.$//"`
|
||||
echo Your hostname is $PUBLIC_HOSTNAME.
|
||||
|
||||
# Start configuration again.
|
||||
# Start configuration again. Hide the terminal. The system services
|
||||
# have not been started yet, so we can't ask the user to create an
|
||||
# account yet.
|
||||
cd /usr/local/mailinabox
|
||||
scripts/start.sh
|
||||
scripts/start.sh < /dev/null
|
||||
fi
|
||||
|
||||
if [ -t 0 ]
|
||||
then
|
||||
# This is an interactive shell. You get a command prompt within
|
||||
# the container.
|
||||
#
|
||||
# You get here by running 'docker run -i -t'.
|
||||
|
||||
echo "Welcome to your Mail-in-a-Box."
|
||||
bash
|
||||
|
||||
else
|
||||
# This is a non-interactive shell. Just display status. Because
|
||||
# other services are running, the container remains running after
|
||||
# this script exits.
|
||||
#
|
||||
# You get here by omitting '-t' from the docker run arguments.
|
||||
|
||||
echo "Your Mail-in-a-Box is running..."
|
||||
fi
|
||||
|
@ -52,6 +52,17 @@ PUBLIC_HOSTNAME=$PUBLIC_HOSTNAME
|
||||
PUBLIC_IP=$PUBLIC_IP
|
||||
EOF
|
||||
|
||||
# For docker, we don't want any of our scripts to start daemons.
|
||||
# Mask the 'service' program by defining a function of the same name
|
||||
# so that whenever we try to restart a service we just silently do
|
||||
# nothing.
|
||||
if [ "$NO_RESTART_SERVICES" == "1" ]; then
|
||||
function service {
|
||||
# we could output some status, but it's not important
|
||||
echo skipping service $@ > /dev/null;
|
||||
}
|
||||
fi
|
||||
|
||||
# Start service configuration.
|
||||
. scripts/system.sh
|
||||
. scripts/dns.sh
|
||||
|
Loading…
Reference in New Issue
Block a user