Amine Baiche
Amine Baiche

Reputation: 11

How to display a messages each time you log in a container

I want to build an image that displays an echo message each time I log in the container My Dockerfile looks like this

FROM python:2 
ENTRYPOINT ['echo','hello you are inside the container']

The problem with this is that I get logged out of the container and I can't use the bash anymore

Upvotes: 0

Views: 1646

Answers (1)

The Fool
The Fool

Reputation: 20537

You can add this to several places, i.e. /etc/profile.d, but you need to make sure you run the shell as login shell, otherwise those scripts like /etc/profile and ~/.bashrc and so are not sourced.

For example:

FROM ubuntu
RUN echo 'echo "welcome to the container"' > /etc/profile.d/welcome.sh
ENTRYPOINT ["/bin/bash", "-l", "-c"]

Upvotes: 1

Related Questions