I often use Docker containers as sandboxes, or as environments containing code that I have worked on and want to use, but don’t want to add to my path. As such, I find myself jumping in and out of containers quite often. I have found it quite useful to set up a message that pops up when you run a container interactively, much like you would get when you run python, octave, ghci, or any other interactive environment. Doing so is very easy, just configure bash to print the welcome message as a part of its initialisation.

FROM debian:jessie
MAINTAINER Ashley Gillman <gillmanash@gmail.com>
# Source working/installation directory
ENV INSTALL /usr/local/src
RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/issue && cat /etc/motd' \
>> /etc/bash.bashrc \
; echo "\
===================================================================\n\
= SomeApp Docker container =\n\
===================================================================\n\
\n\
SomeApp: The appiest app of them all.\n\
(c) Ashley Gillman 2015\n\
\n\
Source directory is $INSTALL\n"\
> /etc/motd
COPY . $INSTALL/someapp
#---------------------------------------------------------------------
# Tini entrypoint
#---------------------------------------------------------------------
# Add Tini init script - take care of runaway processes
ENV TINI_VERSION v0.7.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
CMD ["bash"]
view raw Dockerfile hosted with ❤ by GitHub

All we have done in this example is add

[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/issue && cat /etc/motd

to /etc/bash.bashrc, which tells bash to print the contents of /etc/issue and /etc/motd to the screen if an appropriate terminal is attached. This will print the Linux distribution information and your defined message. If your message is any more complex, you will probably prefer to store it in a separate file and add it to the Docker image using COPY.