ashishpm
ashishpm

Reputation: 491

Docker image should display a message everytime someone runs it

How to build a docker image such that when someone runs a container based on my image a custom message is displayed in the container?

docker run <my-image>
> "This is <name>'s image"

Upvotes: 0

Views: 696

Answers (1)

Harsh Manvar
Harsh Manvar

Reputation: 30160

You have to create the own docker image or use other's docker image which has configuration or code written that way

for example if you will run this

sudo docker run -p 80 -e MSG='This message will be displayed on the web page' --rm wouterm/helloworld

it will print the message as you wanted, if you want to make your own docker image you can also create it.

here is reference code and files : https://github.com/Wouter-M/docker-hello-world

Upvotes: 1

Related Questions