A Docker-based operations shell container that provides a comprehensive set of DevOps tools for cloud operations, Kubernetes management, and infrastructure as code.
ops-shell/
├── Dockerfile # Main Docker image definition
├── README.md # Project documentation
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
├── build.sh # Build script for the Docker image
├── runtime-init.sh # Container initialization script
├── init.sh # Default initialization script
└── ops-shell.sh # Helper script for common operations
- Dockerfile: Defines the container image with all necessary tools and configurations
- runtime-init.sh: Handles container startup and initialization
- init.sh: Default initialization script that runs when container starts
- build.sh: Script to build and tag the Docker image
- ops-shell.sh: Helper script for common operations and shortcuts
Before using OPS-SHELL, ensure you have the following:
-
Docker
- Version 20.10.0 or higher
- Basic understanding of Docker concepts
- Docker Compose (optional)
-
Operating System
- Linux
- macOS
- Windows with WSL2
-
System Requirements
- CPU: 2+ cores recommended
- RAM: 4GB minimum, 8GB recommended
- Storage: 10GB free space minimum
- Network: Stable internet connection
-
Install Docker:
# For Ubuntu/Debian sudo apt-get update sudo apt-get install docker.io docker-compose sudo usermod -aG docker $USER
-
Clone the repository:
git clone https://github.com/hperezrodal/ops-shell.git cd ops-shell
-
Build the image:
./build.sh
-
Cloud Tools:
- AWS CLI v2
- Azure CLI
- Kubernetes (kubectl)
- Helm
- Terraform
- Ansible
-
Development Environment:
- Python 3 with virtual environment
- Common utilities (curl, jq, etc.)
- Bash shell with customization support
-
Bash Library:
- Pre-installed bash library for common operations
- System-wide installation of bash utilities
- Includes Python packages for Kubernetes and AWS operations
- Source: hperezrodal/bash-library
The ops-shell.sh
script provides a convenient way to run the container with different options:
# Just run the shell
./ops-shell.sh
# Run with --no-init flag
./ops-shell.sh --no-init
# Run with environment variables
./ops-shell.sh ENVIRONMENT=uat
# Run with --no-init and environment variables
./ops-shell.sh --no-init ENVIRONMENT=uat
To make the ops-shell command easily accessible from your terminal, add the following alias to your shell configuration file:
For Linux (Bash):
# Add this line to your ~/.bashrc
# source .ops-shell-alias
alias ops-shell='docker run --rm -it \
-v "$(pwd)":/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
ops-shell'
For macOS:
# Add this line to your ~/.zshrc (if using zsh)
alias ops-shell='docker run --rm -it \
-v "$(pwd)":/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
ops-shell'
# Or if using bash, add it to your ~/.bash_profile
alias ops-shell='docker run --rm -it \
-v "$(pwd)":/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
ops-shell'
After adding the alias, either:
- Restart your terminal, or
- Run
source ~/.bashrc
(Linux) orsource ~/.zshrc
(macOS zsh) orsource ~/.bash_profile
(macOS bash) to reload your configuration
Now you can use the ops-shell
command directly from any directory:
# Run with default initialization
ops-shell
# Run without initialization
ops-shell --no-init
# Run with additional arguments
ops-shell --no-init bash
When you run OPS-SHELL without the --no-init
flag, it will execute the initialization script (init.sh
) if present in your workspace:
# Run with default initialization
docker run --rm -it ops-shell
# Example output:
=============================================
Welcome to Ops Shell Container
Build datetime: 2025-04-24T11:59:51Z
=============================================
Available tools:
- kubectl: v1.32.3
- helm: v3.17.3+ge4da497
- aws: aws-cli/2.27.0 Python/3.13.2 Linux/6.8.0-57-generic exe/x86_64.ubuntu.22
- terraform: Terraform v1.11.4
- ansible: ansible [core 2.17.11]
- azure: 2.71.0 2.71.0 1.1.0
- docker: Docker version 28.1.1, build 4eba377
=============================================
Running initialization script...
root@container-id:/workspace#
Use the --no-init
flag to skip the initialization script:
# Run without initialization
docker run --rm -it ops-shell --no-init
# Example output:
=============================================
Welcome to Ops Shell Container
Build datetime: 2025-04-16T13:30:16Z
=============================================
Available tools:
- kubectl: v1.32.3
- helm: v3.17.3+ge4da497
- aws: aws-cli/2.26.2
- terraform: v1.11.4
- ansible: ansible [core 2.18.4]
=============================================
root@container-id:/workspace#
The main difference is that without --no-init
, the container will:
- Look for an
init.sh
script in your workspace - Execute it if found
- Set up any environment variables or configurations defined in the script
You can customize the shell environment by mounting your own initialization script:
docker run --rm -it \
-v $(pwd)/my-init.sh:/workspace/init.sh \
ops-shell
-
Version Control:
- Always use specific versions for tools in the Dockerfile
- Keep track of build dates and versions
-
Security:
- Run as non-root user when possible
- Keep base images updated
- Use multi-stage builds to reduce image size
-
Development:
- Mount your local workspace for persistent changes
- Use environment variables for configuration
- Keep initialization scripts version controlled
./build.sh
- Modify the
Dockerfile
to add or remove tools - Update initialization scripts in
runtime-init.sh
- Rebuild the image using
build.sh
Contributions are always welcome! Please read the contribution guidelines first.
MIT License - See LICENSE file for details
Made with ❤️ by hperezrodal