diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000000000000000000000000000000000000..7dc5a44b2e46276c38083e8e61dd1c7fe2fc4a68
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,6 @@
+.git
+opt/spack
+share/spack/docker/Dockerfile
+share/spack/docker/build-image.sh
+share/spack/docker/run-image.sh
+share/spack/docker/push-image.sh
diff --git a/.travis.yml b/.travis.yml
index 34d8e5c3d3e48adadecd15ff5b8dc591186c7224..d9216fed87ec7ab4f8594a21ee7174665e932b05 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -108,6 +108,11 @@ jobs:
       os: linux
       language: python
       env: [ TEST_SUITE=build, 'SPEC=mpich' ]
+    - stage: 'docker build'
+      sudo: required
+      os: linux
+      language: generic
+      env: TEST_SUITE=docker
   allow_failures:
     - dist: xenial
 
@@ -115,6 +120,8 @@ stages:
   - 'style checks'
   - 'unit tests + documentation'
   - 'build tests'
+  - name: 'docker build'
+    if: type = push AND branch IN (develop, master)
 
 
 #=============================================================================
@@ -187,8 +194,29 @@ before_script:
 #=============================================================================
 # Building
 #=============================================================================
+services:
+  - docker
+
 script:
   - share/spack/qa/run-$TEST_SUITE-tests
+  - if [[ "$TEST_SUITE" == "docker build" ]]; then
+        login_attempted=0; login_success=0;
+        for config in share/spack/docker/config/* ; do
+            source "$config" ;
+            ./share/spack/docker/build-image.sh;
+            if [ "$TRAVIS_EVENT_TYPE" != "pull_request" ]; then
+                if [ "$login_attempted" '=' '0' ]; then
+                    if echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin; then
+                        login_success=1;
+                    fi;
+                    login_attempted=1;
+                fi;
+                if [ "$login_success" '=' '1' ]; then
+                    ./share/spack/docker/push-image.sh;
+                fi
+            fi
+        done;
+    fi
   - if [[ "$TEST_SUITE" == "unit" || "$TEST_SUITE" == "build" ]]; then
         codecov --env PYTHON_VERSION
                 --required --flags "${TEST_SUITE}${TRAVIS_OS_NAME}";
diff --git a/lib/spack/docs/docker_for_developers.rst b/lib/spack/docs/docker_for_developers.rst
index 70d5183011856374abdc3dab02302a619a7aa230..2f1b5a949a29fe699de3fcca53a8d980782ded1d 100644
--- a/lib/spack/docs/docker_for_developers.rst
+++ b/lib/spack/docs/docker_for_developers.rst
@@ -17,13 +17,13 @@ meant to serve as the companion documentation for the :ref:`packaging-guide`.
 Overview
 --------
 
-To get started, all you need is the latest version of ``docker`` and
-``docker-compose``.
+To get started, all you need is the latest version of ``docker``.
 
 .. code-block:: console
 
     $ cd share/spack/docker
-    $ docker-compose run --rm ubuntu
+    $ source config/ubuntu.bash
+    $ ./run-image.sh
 
 This command should drop you into an interactive shell where you can run spack
 within an isolated docker container running ubuntu.  The copy of spack being
@@ -32,13 +32,10 @@ you make should be immediately reflected in the running docker container.  Feel
 free to add or modify any packages or to hack on spack, itself.  Your contained
 copy of spack should immediately reflect all changes.
 
-To work within a container running a different linux distro, change the "ubuntu"
-argument to any one of the services listed under the ``docker-compose.yml``
-file.
+To work within a container running a different linux distro, source one of the
+other environment files under ``config``.
 
 .. code-block:: console
 
-    $ docker-compose config --services
-    fedora
-    ubuntu
-    $ docker-compose run --rm fedora
+    $ source config/fedora.bash
+    $ ./run-image.sh
diff --git a/share/spack/docker/.env b/share/spack/docker/.env
deleted file mode 100644
index 924ceb3f73f69e1935b27e200e49b96bf55813c3..0000000000000000000000000000000000000000
--- a/share/spack/docker/.env
+++ /dev/null
@@ -1 +0,0 @@
-COMPOSE_PROJECT_NAME=spack
diff --git a/share/spack/docker/Dockerfile b/share/spack/docker/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..0c3b49f3665eb72fc5d2a0810613945785b63650
--- /dev/null
+++ b/share/spack/docker/Dockerfile
@@ -0,0 +1,132 @@
+ARG BASE
+
+FROM $BASE
+MAINTAINER Spack Maintainers <maintainers@spack.io>
+
+ARG BASE
+ARG DISTRO
+ARG DISTRO_VERSION
+
+ENV DOCKERFILE_BASE=$BASE                     \
+    DOCKERFILE_DISTRO=$DISTRO                 \
+    DOCKERFILE_DISTRO_VERSION=$DISTRO_VERSION \
+    SPACK_ROOT=/spack                         \
+    FORCE_UNSAFE_CONFIGURE=1                  \
+    DEBIAN_FRONTEND=noninteractive            \
+    container=docker
+
+COPY bin   $SPACK_ROOT/bin
+COPY etc   $SPACK_ROOT/etc
+COPY lib   $SPACK_ROOT/lib
+COPY share $SPACK_ROOT/share
+COPY var   $SPACK_ROOT/var
+RUN mkdir -p $SPACK_ROOT/opt/spack
+
+MASK PUSH
+MASK [[ $DISTRO == arch ]]
+RUN pacman -Sy --noconfirm                                     \
+        base-devel   ca-certificates curl   gcc                \
+        gcc-fortran  git             gnupg2 iproute2           \
+        make         openssh         python python-pip         \
+        sudo         tcl                                       \
+ && echo 'nobody ALL=(ALL) NOPASSWD: ALL' >                    \
+        /etc/sudoers.d/nobody-sudo                             \
+ && sudo -u nobody git clone --depth 1                         \
+        https://aur.archlinux.org/lua-posix.git /tmp/lua-posix \
+ && sudo -u nobody git clone --depth 1                         \
+        https://aur.archlinux.org/lmod.git /tmp/lmod           \
+ && (  cd /tmp/lua-posix                                       \
+    && sudo -u nobody makepkg -si --asdeps --noconfirm )       \
+ && (  cd /tmp/lmod                                            \
+    && sudo -u nobody makepkg -si --noconfirm )                \
+ && rm -rf /tmp/lua-posix /tmp/lmod /etc/sudoers.d/nobody-sudo
+
+MASK [[ $DISTRO =~ (centos|rhel.*) ]]
+RUN yum update -y
+
+  MASK PUSH
+  MASK [[ $DISTRO =~ rhel.* ]]
+  RUN yum install -y yum-conf-repos.noarch \
+   && yum update -y
+  MASK POP
+
+RUN yum install -y epel-release                               \
+ && yum update -y                                             \
+ && yum --enablerepo epel groupinstall -y "Development Tools" \
+ && yum --enablerepo epel install -y                          \
+         curl           findutils gcc-c++    gcc              \
+         gcc-gfortran   git       gnupg2     hostname         \
+         iproute        Lmod      make       patch            \
+         openssh-server python    python-pip tcl              \
+ && rm -rf /var/cache/yum                                     \
+ && yum clean all
+
+MASK [[ $DISTRO == fedora ]]
+RUN dnf update -y                                            \
+ && dnf group install -y "C Development Tools and Libraries" \
+ && dnf install -y                                           \
+        @development-tools                                   \
+        curl            findutils    gcc-c++     gcc         \
+        gcc-gfortran    git          gnupg2      hostname    \
+        iproute         Lmod         make        patch       \
+        openssh-server  python       tcl                     \
+ && dnf clean all
+
+MASK [[ $DISTRO == opensuse ]]
+RUN zypper -n ref                                              \
+ && zypper -n up --skip-interactive --no-recommends            \
+ && zypper -n install -l --no-recommends --type pattern        \
+        devel_basis  devel_C_C++                               \
+ && zypper -n install -l --no-recommends                       \
+        bash        bash-completion ca-certificates curl       \
+        findutils   gcc             gcc-locale      gcc-c++    \
+        gcc-fortran git             glibc-locale    gpg2       \
+        hostname    iproute         lua-lmod        make       \
+        patch       openssh         python          python-pip \
+        python-xml  tcl                                        \
+ && zypper clean                                               \
+ && rm -rf /var/cache/zypp/*
+
+MASK [[ $DISTRO == ubuntu ]]
+RUN apt-get -yqq update                                   \
+ && apt-get -yqq install                                  \
+        build-essential ca-certificates curl       g++    \
+        gcc             gfortran        git        gnupg2 \
+        iproute2        lmod            lua-posix  make   \
+        openssh-server  python          python-pip tcl
+
+  MASK PUSH
+  MASK [[ $DISTRO_VERSION == bionic ]]
+  # [WORKAROUND]
+  # https://bugs.launchpad.net/ubuntu/+source/lua-posix/+bug/1752082
+  RUN ln -s posix_c.so /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so
+  MASK POP
+
+RUN rm -rf /var/lib/apt/lists/*
+
+MASK POP
+
+RUN rm -rf $SPACK_ROOT/.git                                          \
+ && pip install boto3                                                \
+ && (  echo ". /usr/share/lmod/lmod/init/bash"                       \
+    && echo ". $SPACK_ROOT/share/spack/setup-env.sh"                 \
+    && echo ". $SPACK_ROOT/share/spack/spack-completion.bash" )      \
+        >> /etc/profile.d/spack.sh                                   \
+ && ln -s $SPACK_ROOT/share/spack/docker/handle-ssh.sh               \
+        /etc/profile.d/handle-ssh.sh                                 \
+ && ln -s $SPACK_ROOT/share/spack/docker/handle-prompt.sh            \
+        /etc/profile.d/handle-prompt.sh                              \
+ && mkdir -p /root/.spack                                            \
+ && cp $SPACK_ROOT/share/spack/docker/modules.yaml                   \
+        /root/.spack/modules.yaml                                    \
+ && rm -rf /root/*.*
+
+MASK PUSH
+MASK [[ $DISTRO_VERSION =~ (centos|fedora|opensuse|rhel.*) ]]
+RUN rm -f /run/nologin
+MASK POP
+
+WORKDIR /root
+ENTRYPOINT ["bash", "/spack/share/spack/docker/entrypoint.bash"]
+CMD ["docker-shell"]
+
diff --git a/share/spack/docker/build-image.sh b/share/spack/docker/build-image.sh
new file mode 100755
index 0000000000000000000000000000000000000000..fb12bdb833d8e6e591715601394356de31ca6175
--- /dev/null
+++ b/share/spack/docker/build-image.sh
@@ -0,0 +1,84 @@
+#! /usr/bin/env bash
+#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+script="$( basename "$0" )"
+cd "$( dirname "$0" )"
+
+if [ -z "$BASE_IMAGE" ] ; then
+    BASE_IMAGE="ubuntu"
+fi
+
+if [ -z "$BASE_TAG" ] ; then
+    BASE_TAG="latest"
+fi
+
+if [ -z "$DISTRO" ] ; then
+    DISTRO="${BASE_IMAGE}"
+fi
+
+if [ -z "$DISTRO_VERSION" ] ; then
+    DISTRO_VERSION="${BASE_TAG}"
+fi
+
+if [ -z "$BASE_NAME" ] ; then
+    BASE_NAME="${DISTRO}"
+fi
+
+if [ "$BASE_TAG" '=' 'latest' ] ; then
+    BASE_TAG=""
+fi
+
+if [ -n "$BASE_TAG" ] ; then
+    BASE_TAG=":${BASE_TAG}"
+fi
+
+TAG="spack/${BASE_NAME}${BASE_TAG}"
+
+export BASE_IMAGE BASE_TAG DISTRO DISTRO_VERSION BASE_NAME TAG
+
+if [ "$script" '=' 'run-image.sh' ] ; then
+    com="docker run --rm -ti"
+
+    if [ -z "$DISABLE_MOUNT" ] ; then
+        DISABLE_MOUNT=1
+        if [ -z "$*" ] ; then
+            DISABLE_MOUNT=0
+        fi
+    fi
+
+    if [ "$DISABLE_MOUNT" '==' 0 ] ; then
+        com="${com} -v \"$( readlink -f ../../.. ):/spack\""
+    fi
+
+    eval "exec ${com}" "${TAG}" "$@"
+elif [ "$script" '=' 'render-image-template.sh' ] ; then
+    ./dpp.bash Dockerfile
+elif [ "$script" '=' 'push-image.sh' ] ; then
+    docker push "${TAG}"
+    for tag in ${EXTRA_TAGS} ; do
+        docker push "spack/${BASE_NAME}:${tag}"
+    done
+else
+    tag_options="-t ${TAG}"
+    for tag in ${EXTRA_TAGS} ; do
+        tag_options="${tag_options} -t spack/${BASE_NAME}:${tag}"
+    done
+
+    cache_options=""
+    if docker pull "${TAG}" ; then
+        cache_options="--cache-from ${TAG}"
+    fi
+
+    exec ./render-image-template.sh |
+         docker build -f -                                           \
+                      ${cache_options}                               \
+                      ${tag_options}                                 \
+                      --build-arg BASE="${BASE_IMAGE}${BASE_TAG}"    \
+                      --build-arg DISTRO="${DISTRO}"                 \
+                      --build-arg DISTRO_VERSION="${DISTRO_VERSION}" \
+                      ../../..
+fi
diff --git a/share/spack/docker/build/arch.dockerfile b/share/spack/docker/build/arch.dockerfile
deleted file mode 100644
index 6aa9ac0118ed8479377788e0ec770e8f56e4deec..0000000000000000000000000000000000000000
--- a/share/spack/docker/build/arch.dockerfile
+++ /dev/null
@@ -1,59 +0,0 @@
-FROM base/archlinux
-MAINTAINER Omar Padron <omar.padron@kitware.com>
-
-ENV SPACK_ROOT=/spack        \
-    FORCE_UNSAFE_CONFIGURE=1 \
-    DISTRO=arch
-
-RUN pacman -Sy --noconfirm  \
-        base-devel          \
-        ca-certificates     \
-        curl                \
-        gcc                 \
-        gcc-fortran         \
-        git                 \
-        gnupg2              \
-        iproute2            \
-        make                \
-        openssh             \
-        python              \
-        sudo                \
-        tcl              && \
-    git clone --depth 1 git://github.com/spack/spack.git /spack             && \
-    echo 'nobody ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/nobody-sudo      && \
-    sudo -u nobody git clone --depth 1                                         \
-        https://aur.archlinux.org/lua-posix.git /tmp/lua-posix              && \
-    sudo -u nobody git clone --depth 1                                         \
-        https://aur.archlinux.org/lmod.git /tmp/lmod                        && \
-    ( cd /tmp/lua-posix ; sudo -u nobody makepkg -si --asdeps --noconfirm ) && \
-    ( cd /tmp/lmod      ; sudo -u nobody makepkg -si          --noconfirm ) && \
-    rm -rf /tmp/lua-posix /tmp/lmod /spack/.git /etc/sudoers.d/nobody-sudo
-
-RUN ( cd /usr/share/lmod ; ln -s $( ls -d ./* | head -n 1 ) ./lmod )
-
-RUN echo "source /usr/share/lmod/lmod/init/bash" \
-    > /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/setup-env.sh" \
-    >> /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/spack-completion.bash" \
-    >> /etc/profile.d/spack.sh
-
-COPY common/handle-ssh.sh /etc/profile.d/handle-ssh.sh
-COPY common/handle-prompt.sh /etc/profile.d/handle-prompt.sh.source
-
-RUN (                                                         \
-    echo "export DISTRO=$DISTRO"                            ; \
-    echo "if [ x\$PROMPT '!=' 'x' -a x\$PROMPT '!=' 'x0' ]" ; \
-    echo "then"                                             ; \
-    echo "source /etc/profile.d/handle-prompt.sh.source"    ; \
-    echo "fi"                                               ; \
-) > /etc/profile.d/handle-prompt.sh
-
-RUN mkdir -p /root/.spack
-COPY common/modules.yaml /root/.spack/modules.yaml
-
-RUN rm -rf /root/*.*
-
-WORKDIR /root
-ENTRYPOINT ["bash"]
-CMD ["-l"]
diff --git a/share/spack/docker/build/centos.dockerfile b/share/spack/docker/build/centos.dockerfile
deleted file mode 100644
index 20c24b038f8b37b9134640b1d190b6fd6e6e3dd5..0000000000000000000000000000000000000000
--- a/share/spack/docker/build/centos.dockerfile
+++ /dev/null
@@ -1,57 +0,0 @@
-FROM centos
-MAINTAINER Omar Padron <omar.padron@kitware.com>
-
-ENV SPACK_ROOT=/spack        \
-    FORCE_UNSAFE_CONFIGURE=1 \
-    DISTRO=centos
-
-RUN yum update -y               && \
-    yum install -y epel-release && \
-    yum update -y               && \
-    yum groupinstall -y "Development Tools" && \
-    yum install -y            \
-        curl                  \
-        findutils             \
-        gcc-c++               \
-        gcc                   \
-        gcc-gfortran          \
-        git                   \
-        gnupg2                \
-        hostname              \
-        iproute               \
-        Lmod                  \
-        make                  \
-        patch                 \
-        openssh-server        \
-        python                \
-        tcl                && \
-    git clone --depth 1 git://github.com/spack/spack.git /spack && \
-    rm -rf /spack/.git /var/cache/yum && yum clean all
-
-RUN echo "source /usr/share/lmod/lmod/init/bash" \
-    > /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/setup-env.sh" \
-    >> /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/spack-completion.bash" \
-    >> /etc/profile.d/spack.sh
-COPY common/handle-ssh.sh /etc/profile.d/handle-ssh.sh
-COPY common/handle-prompt.sh /etc/profile.d/handle-prompt.sh.source
-
-RUN (                                                         \
-    echo "export DISTRO=$DISTRO"                            ; \
-    echo "if [ x\$PROMPT '!=' 'x' -a x\$PROMPT '!=' 'x0' ]" ; \
-    echo "then"                                             ; \
-    echo "source /etc/profile.d/handle-prompt.sh.source"    ; \
-    echo "fi"                                               ; \
-) > /etc/profile.d/handle-prompt.sh
-
-RUN mkdir -p /root/.spack
-COPY common/modules.yaml /root/.spack/modules.yaml
-
-RUN rm -f /run/nologin
-
-RUN rm -rf /root/*.*
-
-WORKDIR /root
-ENTRYPOINT ["bash"]
-CMD ["-l"]
diff --git a/share/spack/docker/build/fedora.dockerfile b/share/spack/docker/build/fedora.dockerfile
deleted file mode 100644
index bf06411d212e589edb01e8633a2416ec9e3d4df9..0000000000000000000000000000000000000000
--- a/share/spack/docker/build/fedora.dockerfile
+++ /dev/null
@@ -1,56 +0,0 @@
-FROM fedora:24
-MAINTAINER Omar Padron <omar.padron@kitware.com>
-
-ENV SPACK_ROOT=/spack        \
-    FORCE_UNSAFE_CONFIGURE=1 \
-    DISTRO=fedora
-
-RUN dnf update -y && \
-    dnf group install -y "C Development Tools and Libraries" && \
-    dnf install -y            \
-        @development-tools    \
-        curl                  \
-        findutils             \
-        gcc-c++               \
-        gcc                   \
-        gcc-gfortran          \
-        git                   \
-        gnupg2                \
-        hostname              \
-        iproute               \
-        Lmod                  \
-        make                  \
-        patch                 \
-        openssh-server        \
-        python                \
-        tcl                && \
-    git clone --depth 1 git://github.com/spack/spack.git /spack && \
-    rm -rf /spack/.git && dnf clean all
-
-RUN echo "source /usr/share/lmod/lmod/init/bash" \
-    > /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/setup-env.sh" \
-    >> /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/spack-completion.bash" \
-    >> /etc/profile.d/spack.sh
-COPY common/handle-ssh.sh /etc/profile.d/handle-ssh.sh
-COPY common/handle-prompt.sh /etc/profile.d/handle-prompt.sh.source
-
-RUN (                                                         \
-    echo "export DISTRO=$DISTRO"                            ; \
-    echo "if [ x\$PROMPT '!=' 'x' -a x\$PROMPT '!=' 'x0' ]" ; \
-    echo "then"                                             ; \
-    echo "source /etc/profile.d/handle-prompt.sh.source"    ; \
-    echo "fi"                                               ; \
-) > /etc/profile.d/handle-prompt.sh
-
-RUN mkdir -p /root/.spack
-COPY common/modules.yaml /root/.spack/modules.yaml
-
-RUN rm -f /run/nologin
-
-RUN rm -rf /root/*.*
-
-WORKDIR /root
-ENTRYPOINT ["bash"]
-CMD ["-l"]
diff --git a/share/spack/docker/build/opensuse.dockerfile b/share/spack/docker/build/opensuse.dockerfile
deleted file mode 100644
index 46189a41c995f2d7042307d979b7c0a7b992ff62..0000000000000000000000000000000000000000
--- a/share/spack/docker/build/opensuse.dockerfile
+++ /dev/null
@@ -1,65 +0,0 @@
-FROM opensuse
-MAINTAINER Omar Padron <omar.padron@kitware.com>
-
-ENV SPACK_ROOT=/spack        \
-    FORCE_UNSAFE_CONFIGURE=1 \
-    DISTRO=opensuse
-
-RUN zypper -n ref                                        && \
-    zypper -n up --skip-interactive --no-recommends      && \
-    zypper -n install -l --no-recommends --type pattern     \
-        devel_basis                                         \
-        devel_C_C++                                      && \
-    zypper -n install -l --no-recommends                    \
-        bash                                                \
-        bash-completion                                     \
-        ca-certificates                                     \
-        curl                                                \
-        findutils                                           \
-        gcc                                                 \
-        gcc-locale                                          \
-        gcc-c++                                             \
-        gcc-fortran                                         \
-        git                                                 \
-        glibc-locale                                        \
-        gpg2                                                \
-        hostname                                            \
-        iproute                                             \
-        lua-lmod                                            \
-        make                                                \
-        patch                                               \
-        openssh                                             \
-        python                                              \
-        python-xml                                          \
-        tcl                                              && \
-    git clone --depth 1 git://github.com/spack/spack.git /spack && \
-    zypper clean                                                && \
-    rm -rf /spack/.git /var/cache/zypp/*
-
-RUN echo "source /usr/share/lmod/lmod/init/bash" \
-    > /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/setup-env.sh" \
-    >> /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/spack-completion.bash" \
-    >> /etc/profile.d/spack.sh
-COPY common/handle-ssh.sh /etc/profile.d/handle-ssh.sh
-COPY common/handle-prompt.sh /etc/profile.d/handle-prompt.sh.source
-
-RUN (                                                         \
-    echo "export DISTRO=$DISTRO"                            ; \
-    echo "if [ x\$PROMPT '!=' 'x' -a x\$PROMPT '!=' 'x0' ]" ; \
-    echo "then"                                             ; \
-    echo "source /etc/profile.d/handle-prompt.sh.source"    ; \
-    echo "fi"                                               ; \
-) > /etc/profile.d/handle-prompt.sh
-
-RUN mkdir -p /root/.spack
-COPY common/modules.yaml /root/.spack/modules.yaml
-
-RUN rm -f /run/nologin
-
-RUN rm -rf /root/*.*
-
-WORKDIR /root
-ENTRYPOINT ["bash"]
-CMD ["-l"]
diff --git a/share/spack/docker/build/scilinux.dockerfile b/share/spack/docker/build/scilinux.dockerfile
deleted file mode 100644
index 3827f5f60e71b0bec4f7d1ebde231323daadc27e..0000000000000000000000000000000000000000
--- a/share/spack/docker/build/scilinux.dockerfile
+++ /dev/null
@@ -1,62 +0,0 @@
-FROM sl:7
-MAINTAINER Patrick Gartung (gartung@fnal.gov)
-
-ENV SPACK_ROOT=/spack     \
-    FORCE_UNSAFE_CONFIGURE=1 \
-    DISTRO=rhel7 \
-    container=docker
-
-RUN yum update -y               && \
-    yum install -y yum-conf-repos.noarch && \
-    yum update -y               && \
-    yum -y install epel-release && \
-    yum update -y               && \
-    yum --enablerepo epel \
-    groupinstall -y "Development Tools" && \
-    yum --enablerepo epel \
-        install -y            \
-        curl                  \
-        findutils             \
-        gcc-c++               \
-        gcc                   \
-        gcc-gfortran          \
-        git                   \
-        gnupg2                \
-        hostname              \
-        iproute               \
-        Lmod                  \
-        make                  \
-        patch                 \
-        openssh-server        \
-        python                \
-        tcl                
-RUN    git clone --depth=1 git://github.com/spack/spack.git /spack && \
-       rm -rf /var/cache/yum /spack/.git && yum clean all
-
-RUN echo "source /usr/share/lmod/lmod/init/bash" \
-    > /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/setup-env.sh" \
-    >> /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/spack-completion.bash" \
-    >> /etc/profile.d/spack.sh
-COPY common/handle-ssh.sh /etc/profile.d/handle-ssh.sh
-COPY common/handle-prompt.sh /etc/profile.d/handle-prompt.sh.source
-
-RUN (                                                         \
-    echo "export DISTRO=$DISTRO"                            ; \
-    echo "if [ x\$PROMPT '!=' 'x' -a x\$PROMPT '!=' 'x0' ]" ; \
-    echo "then"                                             ; \
-    echo "source /etc/profile.d/handle-prompt.sh.source"    ; \
-    echo "fi"                                               ; \
-) > /etc/profile.d/handle-prompt.sh
-
-RUN mkdir -p /root/.spack
-COPY common/modules.yaml /root/.spack/modules.yaml
-
-RUN rm -f /run/nologin
-
-RUN rm -rf /root/*.*
-
-WORKDIR /root
-ENTRYPOINT ["bash"]
-CMD ["-l"]
diff --git a/share/spack/docker/build/ubuntu.dockerfile b/share/spack/docker/build/ubuntu.dockerfile
deleted file mode 100644
index ac608ddd12c63b4a8a0afe0d4b41395f31b0bdc3..0000000000000000000000000000000000000000
--- a/share/spack/docker/build/ubuntu.dockerfile
+++ /dev/null
@@ -1,51 +0,0 @@
-FROM ubuntu
-MAINTAINER Omar Padron <omar.padron@kitware.com>
-
-ENV DEBIAN_FRONTEND=noninteractive \
-    SPACK_ROOT=/spack              \
-    FORCE_UNSAFE_CONFIGURE=1       \
-    DISTRO=ubuntu
-
-RUN apt-get -yqq update && apt-get -yqq install \
-        build-essential     \
-        ca-certificates     \
-        curl                \
-        g++                 \
-        gcc                 \
-        gfortran            \
-        git                 \
-        gnupg2              \
-        lmod                \
-        make                \
-        openssh-server      \
-        python              \
-        tcl              && \
-    git clone --depth 1 git://github.com/spack/spack.git /spack && \
-    rm -rf /spack/.git && rm -rf /var/lib/apt/lists/*
-
-RUN echo "source /usr/share/lmod/lmod/init/bash" \
-    > /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/setup-env.sh" \
-    >> /etc/profile.d/spack.sh
-RUN echo "source /spack/share/spack/spack-completion.bash" \
-    >> /etc/profile.d/spack.sh
-COPY common/handle-ssh.sh /etc/profile.d/handle-ssh.sh
-COPY common/handle-prompt.sh /etc/profile.d/handle-prompt.sh.source
-
-
-RUN (                                                         \
-    echo "export DISTRO=$DISTRO"                            ; \
-    echo "if [ x\$PROMPT '!=' 'x' -a x\$PROMPT '!=' 'x0' ]" ; \
-    echo "then"                                             ; \
-    echo "source /etc/profile.d/handle-prompt.sh.source"    ; \
-    echo "fi"                                               ; \
-) > /etc/profile.d/handle-prompt.sh
-
-RUN mkdir -p /root/.spack
-COPY common/modules.yaml /root/.spack/modules.yaml
-
-RUN rm -rf /root/*.*
-
-WORKDIR /root
-ENTRYPOINT ["bash"]
-CMD ["-l"]
diff --git a/share/spack/docker/config/arch.bash b/share/spack/docker/config/arch.bash
new file mode 100644
index 0000000000000000000000000000000000000000..3cb2951c4bd84f36a62fa7f195b1625030350c7a
--- /dev/null
+++ b/share/spack/docker/config/arch.bash
@@ -0,0 +1,18 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE="base/archlinux"
+export BASE_NAME="archlinux"
+export BASE_TAG="2018.10.01"
+export DISTRO="arch"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/centos.bash b/share/spack/docker/config/centos.bash
new file mode 100644
index 0000000000000000000000000000000000000000..bef7ad276b5e7bc596d2929a39c2171a30b01fd1
--- /dev/null
+++ b/share/spack/docker/config/centos.bash
@@ -0,0 +1,16 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=centos
+export BASE_TAG="7"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/fedora.bash b/share/spack/docker/config/fedora.bash
new file mode 100644
index 0000000000000000000000000000000000000000..fcf7425693223fa19de1b9b1fa58be547f1d664a
--- /dev/null
+++ b/share/spack/docker/config/fedora.bash
@@ -0,0 +1,16 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=fedora
+export BASE_TAG="24"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/opensuse.bash b/share/spack/docker/config/opensuse.bash
new file mode 100644
index 0000000000000000000000000000000000000000..b0e11c17acdaadff91ff1dda9a0e0aefa6b9cb33
--- /dev/null
+++ b/share/spack/docker/config/opensuse.bash
@@ -0,0 +1,16 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset DISTRO_VERSION
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=opensuse
+export BASE_TAG="tumbleweed"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/scilinux.bash b/share/spack/docker/config/scilinux.bash
new file mode 100644
index 0000000000000000000000000000000000000000..71fd737f69ea7280a466316136c9c1bf55000799
--- /dev/null
+++ b/share/spack/docker/config/scilinux.bash
@@ -0,0 +1,17 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=sl
+export BASE_TAG="7"
+export BASE_NAME=scilinux
+export DISTRO=rhel7
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/config/ubuntu.bash b/share/spack/docker/config/ubuntu.bash
new file mode 100644
index 0000000000000000000000000000000000000000..588848fb40ada25aafd89825358392f540e1096d
--- /dev/null
+++ b/share/spack/docker/config/ubuntu.bash
@@ -0,0 +1,15 @@
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+unset DISTRO
+unset BASE_IMAGE
+unset BASE_NAME
+unset BASE_TAG
+unset TAG
+unset EXTRA_TAGS
+
+export BASE_IMAGE=ubuntu
+export BASE_TAG="bionic"
+export EXTRA_TAGS="latest"
diff --git a/share/spack/docker/docker-compose.yml b/share/spack/docker/docker-compose.yml
deleted file mode 100644
index 4f37127e3f68c7590e5c023a7ee2ece66084e6e4..0000000000000000000000000000000000000000
--- a/share/spack/docker/docker-compose.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-version: '3'
-services:
-  arch:
-    build:
-      context: build
-      dockerfile: arch.dockerfile
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
-  centos:
-    build:
-      context: build
-      dockerfile: centos.dockerfile
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
-  fedora:
-    build:
-      context: build
-      dockerfile: fedora.dockerfile
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
-  opensuse:
-    build:
-      context: build
-      dockerfile: opensuse.dockerfile
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
-  scilinux:
-    build:
-      context: build
-      dockerfile: scilinux.dockerfile
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
-  scilinux:
-    build: ./spack_scilinux
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
-  ubuntu:
-    build:
-      context: build
-      dockerfile: ubuntu.dockerfile
-    volumes:
-      - '../../..:/spack'
-    environment:
-      PROMPT: "${PROMPT:-0}"
diff --git a/share/spack/docker/dpp.bash b/share/spack/docker/dpp.bash
new file mode 100755
index 0000000000000000000000000000000000000000..f41a9c5260b6341022223b05ca6293e68462c664
--- /dev/null
+++ b/share/spack/docker/dpp.bash
@@ -0,0 +1,77 @@
+#! /usr/bin/env bash
+#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+function prefix_tokens() {
+    line="$1" ; shift
+    nprefix="$1"
+
+    line="${line::$nprefix} "
+    echo "${line::$nprefix}"
+}
+
+
+# read file contents, or stdin
+cat "$1" |
+
+# remove blank lines
+grep -v '^ *$' |
+
+# remove leading whitespace
+sed 's/^ *//g' |
+
+# remove comments
+grep -v '^#.*' |
+
+# remove trailing whitespace
+sed 's/ *$//g' |
+
+# remove extraneous whitespace
+sed 's/  */ /g' |
+
+# mask out subsections
+(
+    stack_level=1
+    mask_level=1
+
+    while read LINE ; do
+        try_print=1
+
+        if [ "$( prefix_tokens "$LINE" 10 )" '=' 'MASK PUSH ' ] ; then
+            tmp="$stack_level"
+            stack_level="$(( stack_level + 1 ))"
+            if [ "$mask_level" '=' "$tmp" ] ; then
+                mask_level="$stack_level"
+            fi
+            try_print=0
+        elif [ "$( prefix_tokens "$LINE" 9 )" '=' 'MASK POP ' ] ; then
+            stack_level="$(( stack_level - 1 ))"
+            if [ "$mask_level" -gt "$stack_level" ] ; then
+                mask_level="$stack_level"
+            fi
+            try_print=0
+        elif [ "$( prefix_tokens "$LINE" 5 )" '=' 'MASK ' ] ; then
+            if [ "$(( mask_level + 1 ))" -ge "$stack_level" ] ; then
+                mask_level="$stack_level"
+                eval "${LINE:5}"
+                if [ "$?" '!=' 0 ] ; then
+                    mask_level="$(( mask_level - 1 ))"
+                fi
+            fi
+            try_print=0
+        fi
+
+        if [ "$stack_level" -lt 1 ] ; then
+            stack_level=1
+            mask_level=0
+        fi
+
+        if [ "$try_print" '=' 1 -a "$mask_level" '=' "$stack_level" ] ; then
+            echo "$LINE"
+        fi
+    done
+)
+
diff --git a/share/spack/docker/entrypoint.bash b/share/spack/docker/entrypoint.bash
new file mode 100755
index 0000000000000000000000000000000000000000..58d6281084f51e1b6738cf4637e2f4484266fae8
--- /dev/null
+++ b/share/spack/docker/entrypoint.bash
@@ -0,0 +1,43 @@
+#! /usr/bin/env bash -e
+#
+# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+if [ "$1" '=' 'docker-shell' ] ; then
+    if [ -t 0 ] ; then
+        exec bash -il
+    else
+        (
+            echo -n "It looks like you're trying to run an intractive shell"
+            echo -n " session, but either no psuedo-TTY is allocateed for this"
+            echo -n " container's STDIN, or it is closed."
+            echo
+
+            echo -n "Make sure you run docker with the --interactive and --tty"
+            echo -n " options."
+            echo
+        ) >&2
+
+        exit 1
+    fi
+else
+    exec 3>&1
+    exec 4>&2
+
+    exec 1>&-
+    exec 2>&-
+
+    source /etc/profile.d/spack.sh
+    source /etc/profile.d/handle-ssh.sh
+
+    exec 1>&3
+    exec 2>&4
+
+    exec 3>&-
+    exec 4>&-
+
+    spack "$@"
+    exit $?
+fi
diff --git a/share/spack/docker/build/common/handle-prompt.sh b/share/spack/docker/handle-prompt.sh
similarity index 96%
rename from share/spack/docker/build/common/handle-prompt.sh
rename to share/spack/docker/handle-prompt.sh
index 5a4910e3fa699062d1bbf050d343cc4722e7ce5f..d523ac3a31fb1999304642eddaefe4946458b161 100644
--- a/share/spack/docker/build/common/handle-prompt.sh
+++ b/share/spack/docker/handle-prompt.sh
@@ -3,6 +3,8 @@
 #
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
+if [ x$SPACK_PROMPT '!=' x0 ] ; then
+
 __tmp="`mktemp -d`"
 
 __trylock() {
@@ -83,7 +85,7 @@ __git_head() {
 __update_prompt() {
     local prompt
     prompt=''
-    linux_distro="$DISTRO"
+    linux_distro="$DOCKERFILE_DISTRO"
     if [ -n "$linux_distro" ] ; then
         linux_distro='\[\e[1;34m\][\[\e[0;34m\]'"$linux_distro"'\[\e[1;34m\]]'
         if [ -n "$prompt" ] ; then
@@ -163,3 +165,5 @@ __update_prompt_main() {
 }
 
 PROMPT_COMMAND=__update_prompt_main
+
+fi # [ x$SPACK_PROMPT '!=' x0 ]
diff --git a/share/spack/docker/build/common/handle-ssh.sh b/share/spack/docker/handle-ssh.sh
similarity index 100%
rename from share/spack/docker/build/common/handle-ssh.sh
rename to share/spack/docker/handle-ssh.sh
diff --git a/share/spack/docker/build/common/modules.yaml b/share/spack/docker/modules.yaml
similarity index 100%
rename from share/spack/docker/build/common/modules.yaml
rename to share/spack/docker/modules.yaml
diff --git a/share/spack/docker/push-image.sh b/share/spack/docker/push-image.sh
new file mode 120000
index 0000000000000000000000000000000000000000..9e5dfdf52d1eb830a16798db9129eef89f0c0c41
--- /dev/null
+++ b/share/spack/docker/push-image.sh
@@ -0,0 +1 @@
+./build-image.sh
\ No newline at end of file
diff --git a/share/spack/docker/render-image-template.sh b/share/spack/docker/render-image-template.sh
new file mode 120000
index 0000000000000000000000000000000000000000..9e5dfdf52d1eb830a16798db9129eef89f0c0c41
--- /dev/null
+++ b/share/spack/docker/render-image-template.sh
@@ -0,0 +1 @@
+./build-image.sh
\ No newline at end of file
diff --git a/share/spack/docker/run-image.sh b/share/spack/docker/run-image.sh
new file mode 120000
index 0000000000000000000000000000000000000000..b3fd71be2432f5c8ced5b5f0b4a4bafc5d8d6560
--- /dev/null
+++ b/share/spack/docker/run-image.sh
@@ -0,0 +1 @@
+build-image.sh
\ No newline at end of file