Skip to content

f-4-u/coursecontent-dockerized-greeter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coursecontent-dockerized-greeter

This repository contains a Dockerized version of the Course Content Greeter script available at f-4-u/coursecontent-greeter.

Description

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.


Usage

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 the Docker image

docker-compose build

Run the Docker container

docker-compose up

Docker

Docker Build Command

docker build -t greeter:latest .

Docker Run Command

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 arguments

./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

License

This project is licensed under the GNU General Public License (GPL) - see the LICENSE file for details.

About

The bash greeter script is now dockerzied

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published