Skip to content

Yundera/pre-install-toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pre-Install Toolbox

A lightweight Docker container for executing shell scripts from local files, remote URLs, or multiline strings.

Overview

The Pre-Install Toolbox is a minimal Alpine-based Docker container that provides a convenient way to run shell scripts from multiple sources:

  • Local files mounted into the container
  • Remote URLs (downloaded and executed)
  • Multiline script strings passed as arguments

It includes essential tools like curl and wget for fetching remote scripts.

Usage

Running a remote script

docker run nasselle/pre-install-toolbox:1.0.0 https://example.com/script.sh

Running a multiline script string

docker run nasselle/pre-install-toolbox:1.0.0 "
#!/bin/sh
echo 'Hello from multiline script!'
ls -la /
echo 'Script completed'
"

Or with a more complex example:

docker run nasselle/pre-install-toolbox:1.0.0 "
set -e
echo 'Starting installation...'
apk update
apk add --no-cache git vim
echo 'Installation completed successfully!'
"

Running a local script

Mount your script as /script.sh in the container:

docker run -v $(pwd)/my-script.sh:/script.sh nasselle/pre-install-toolbox:1.0.0

Passing arguments to the script

You can pass additional arguments to any script (URL or multiline string):

# With URL
docker run nasselle/pre-install-toolbox:1.0.0 https://example.com/script.sh arg1 arg2

# With multiline string
docker run nasselle/pre-install-toolbox:1.0.0 "
echo 'First argument:' \$1
echo 'Second argument:' \$2
" arg1 arg2

How It Works

  1. If no parameters are provided, the container looks for a /script.sh file to execute
  2. If the first parameter starts with http:// or https://, it downloads and executes the script from that URL
  3. If the first parameter doesn't start with a URL scheme, it treats it as a multiline script string and executes it directly
  4. Any additional parameters are passed to the script as arguments

Building the Image

docker build -t nasselle/pre-install-toolbox:1.0.0 .

Project Structure

  • Dockerfile - Container definition
  • entrypoint.sh - Container entry point script
  • dockflow.json - Image metadata

Security Considerations

Warning:

  • Running scripts directly from URLs can be a security risk. Always verify the source and content of scripts before execution.
  • When using multiline strings, be careful with shell escaping and avoid executing untrusted input.
  • Consider the security implications of any scripts you run, especially those that modify system state.

Examples

Simple system information script

docker run nasselle/pre-install-toolbox:1.0.0 "
echo '=== System Information ==='
uname -a
echo '=== Disk Usage ==='
df -h
echo '=== Memory Usage ==='
free -h
"

Package installation script

docker run nasselle/pre-install-toolbox:1.0.0 "
#!/bin/sh
set -e
echo 'Installing development tools...'
apk update
apk add --no-cache git curl vim bash
echo 'Development tools installed successfully!'
git --version
"

License

MIT

About

The Pre-Install Toolbox is a minimal Alpine-based Docker container that provides a convenient way to run shell scripts

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors