This repository contains a Dockerized version of the Course Content Greeter script available at f-4-u/coursecontent-greeter.
The Course Content Dockerized Greeter script is designed to greet users and log their interactions in a course content system. By Dockerizing the script, it can be easily deployed and run in a containerized environment.
Translation of the exercise description:
Exercise Description: "Try to run your script in a Docker container automatically. The container should load the script from an external source."
Task: Create a Dockerized version of the Course Content Greeter script that automatically greets users and logs their interactions in a course content system. The script should run within a Docker container and load the necessary components from an external source.
To run the Course Content Dockerized Greeter script, follow these steps:
Clone this repository:
git clone https://github.com/f-4-u/coursecontent-dockerized-greeter.git
Navigate to the cloned directory:
cd coursecontent-dockerized-greeter
docker-compose build
docker-compose up
docker build -t greeter:latest .
docker run -it --name greeter -v $(pwd)/log:/log greeter:latest greeter -l /log/user.log root greatuser
In this command:
-v $(pwd)/log:/log
creates a persistent volume by mounting the log directory from the current host directory ($(pwd)) to the /log directory inside the container. This ensures that logs generated by the container are persisted on the host machine even after the container is stopped or removed.$(pwd)/log
specifies the path to the host directory containing the log files./log
specifies the path to where the volume will be mounted inside the container.greeter:latest
is the name of the Docker image.greeter
-l /log/user.log
root
greatuser
are the arguments passed to the greeter script inside the container.
# Examples:
docker run --rm -it greeter:latest greeter -l /tmp/mylog.log user1 user2
docker run --rm -it greeter:latest greeter user3 user4
./greeter.sh [-l <log_file>] [-k <lock_file>] [-a] [username1] [username2] ...
Options:
-a Greet all users with an interactive shell.
-l <log_file> Specify a custom log file location (default: ${HOME}/greetings.log).
-k <lock_file> Specify a custom lock file location (default: /tmp/greeter.lock).
-s Show users with an interactive shell and exit.
-h Show this help message and exit.
Examples:
./greeter.sh -a
./greeter.sh -s
./greeter.sh -l /path/to/custom/logfile -k /path/to/custom/lockfile user1 user2
This project is licensed under the GNU General Public License (GPL) - see the LICENSE file for details.