Introduction
Ahoy, Docker linguist! You've mastered making the Docker whale speak, but can you make it multilingual? In this challenge, you'll create a Docker image that uses environment variables to change the language of the whale's greeting. Get ready to give our cetacean friend a global voice!
Create a Polyglot Whale
Imagine you're developing a multilingual application, and you need a way to quickly test your Docker setup in different language environments. That's where our polyglot whale comes in!
In this challenge, you'll take your Docker skills to the next level by creating a flexible, language-aware container. You'll use environment variables - a powerful tool in the Docker ecosystem - to dynamically change the language of our friendly Docker whale's greeting.
Before we dive in, let's set up your challenge environment. Navigate to the ~/project/docker directory in your terminal. You'll find some starter files there, courtesy of your Docker mentor. These files will give you a head start, allowing you to focus on the core concepts of this challenge.
Ready to give our cetacean friend a global voice? Let's make waves in the world of multilingual containers!
Tasks
Your linguistic mission, should you choose to accept it, is to:
- Examine the provided
entrypoint.shscript to understand how it handles different languages. - Modify the
Dockerfileto incorporate theentrypoint.shscript and set up environment variables. - Build a Docker image from your completed Dockerfile.
- Run containers from your image, experimenting with different language settings.
Requirements
To successfully complete this challenge, you must:
- Use the
docker/whalesayas the base image in your Dockerfile. - Create an environment variable named
WHALE_LANGUAGEin your Dockerfile, with a default value of "English". - Use the
COPYinstruction in yourDockerfileto copy the providedentrypoint.shscript into the root directory (/) of your image, naming it/entrypoint.sh. Ensure it has execute permissions and set it as theENTRYPOINT. - Build your image with the tag
polyglot-whale. - Run your container with the environment variable set to make the whale speak both English and Spanish.
- Execute all commands in the
~/project/dockerdirectory.
Remember, the entrypoint.sh script is already provided for you. Your main task is to create a Dockerfile that correctly utilizes this script and allows for language customization via environment variables.
Example
When you run your container with Spanish selected, you should see output similar to this:
docker run -e WHALE_LANGUAGE=Spanish polyglot-whale
_________
< ¡Hola! >
---------
\
\
\
### .
### ### ### ==
### ### ### ### ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
And when run with the default English setting:
docker run polyglot-whale
_________
< Hello! >
---------
\
\
\
### .
### ### ### ==
### ### ### ### ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
Summary
In this challenge, you've expanded your Docker skills by creating an image that uses environment variables for configuration. You've learned how to:
- Use environment variables in a Dockerfile to set default values.
- Create a simple shell script to act as an entrypoint for your container.
- Override environment variables when running a container.
These skills are crucial for creating flexible, configurable Docker images that can adapt to different environments or use cases. As you continue your Docker journey, remember that environment variables are a powerful tool for making your containers more versatile and easier to manage across different deployment scenarios. Keep exploring and happy whale-speaking!



