Personalize The Greeting
Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 36 of 40.
Challenge
MediumMake the greeting read from a file you ship inside the image. A file named name.txt (containing a user's name) is already in your directory. Run these commands one after the other:
- Write a Dockerfile:
FROM alpine, thenCOPY name.txt /name.txt, thenCMD ["cat", "/name.txt"] - Build it tagged
greetapp - Run it so the name prints
Try it yourself
Terminal
cat > Dockerfile << 'EOF'
FROM alpine
CMD ["echo", "Welcome to the greeting app"]
EOF
docker build -t greetapp .
docker run greetappAll lessons in Introduction to Docker
4Managing Containers
Naming ContainersDetached ContainersListing All ContainersStopping And RemovingRecap - Container Lifecycle10Greeting App Project
Project OverviewWrite The Dockerfile