Skip to content

Python Wolfi-based Docker Image: nnthanh101/pythonΒΆ

OverviewΒΆ

The nnthanh101/python:cloudops image is a secure, lightweight, and production-grade Python environment built on Chainguard's Wolfi Base. This image has been optimized to support multi-cloud environments (AWS, Azure) and cross-platform workflows for analytics, automation, and data science projects.

With a focus on modern CloudOps and DevOps practices, this image incorporates security, maintainability, and scalability into its design. It integrates essential extensions like JupyterLab, Vizro, and MkDocs for analytics and documentation workflows.


Key FeaturesΒΆ

  • Lightweight and Secure:
  • Built on cgr.dev/chainguard/wolfi-base:cloudops, prioritizing security with minimal attack surface.
  • Non-root os user pre-configured to ensure security.
  • Cross-Platform Support: Supports multiple architectures, including linux/amd64 and linux/arm64.

Chainguard's Wolfi Docker Images

  • Cloud-Native Utilities: Pre-installed tools like starship, task, git-lfs, and support for pre-configured Python 3.12 virtual environment support for compatibility with modern workflows. Integrated also with awscli, azure-cli, and ansible for provisioning and automation.

  • Pre-Bundled Python Extensions: Categorized for analytics, documentation, and cloud operations with AWS CLI, and Azure CLI.


UsageΒΆ

Run a Python Shell and TasklistΒΆ

Syntax: docker run -it -p 8888:8888 -v LOCAL_FOLDER:REMOTE_FOLDER registry/image

docker run -it --rm nnthanh101/python:cloudops python

## Run a Tasklist
docker run -it --rm nnthanh101/python:cloudops task

Run with Data MountingΒΆ

  • ## TODO: -e DEBUG=1 &&
export HOST_AWS="$HOME/.aws"

docker run -it -p 8888:8888 \
  -v "$(pwd):/workspace:rw" \
  -v "${HOST_AWS}:/workspace/.aws:ro" \
  --user $(id -u):$(id -g) \
  nnthanh101/python:cloudops

Use for JupyterLabΒΆ

USERNAME=os

docker run -it -p 8888:8888 \
 -v $HOME/notebooks:/home/$USERNAME/notebooks \
 nnthanh101/python:cloudops jupyter lab --ip=0.0.0.0 --no-browser

Extend the ImageΒΆ

To add custom Python packages:

FROM nnthanh101/python:cloudops

COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

DevContainer UsageΒΆ

  • Project/Folder Structure:

Ensure the host project directory is structured as follows:

β”œβ”€β”€ .devcontainer       ## VS Code DevContainer configuration
β”‚   β”œβ”€β”€ devcontainer.json
β”œβ”€β”€ projects            ## Your code and Python projects
β”œβ”€β”€ credentials         ## AWS credentials, config files, etc.
β”œβ”€β”€ data                ## Raw and processed data files
  • Run Command via VS Code:
  1. Open the project folder in VS Code.
  2. Press Ctrl+Shift+P, select Remote-Containers: Open Folder in Container....
  3. Choose the folder containing .devcontainer.

Technical Notes - Python Extensions:ΒΆ

  • βœ… nnthanh101/python:jupyterlab
  • β˜‘οΈ nnthanh101/python:techdocs
  • βœ…β˜‘οΈ nnthanh101/python:latest
  • βœ”οΈ nnthanh101/python:cloudops
  • nnthanh101/python:analytics
βœ… Python Extension Category Description Relevant URL
βœ”οΈ ansible Automation Configuration management and orchestration tool. Ansible Docs
βœ”οΈ awscli Cloud Management Command-line interface for AWS services. AWS CLI Docs
βœ”οΈ azure-cli Cloud Management Command-line tools for managing Azure resources. Azure CLI Docs
βœ”οΈ boto3 Cloud Management AWS SDK for Python to automate and manage AWS services programmatically. Boto3 Docs
MkDocs Extensions
β˜‘οΈ mkdocs Documentation Tools A static site generator for project documentation. MkDocs Docs
β˜‘οΈ mkdocs-material Documentation Tools A modern, responsive theme for MkDocs. Material Theme
β˜‘οΈ mkdocstrings Documentation Tools Plugin for documenting Python code using docstrings. MkDocstrings
β˜‘οΈ mkdocstrings[python] Documentation Tools Enhanced Python support for mkdocstrings. MkDocstrings Python
β˜‘οΈ mkdocs-drawio-exporter Documentation Tools Export draw.io diagrams to integrate with MkDocs. DrawIO Exporter
β˜‘οΈ pymdown-extensions Documentation Tools Markdown extensions for advanced formatting. Pymdown Extensions
β˜‘οΈ pygments Documentation Tools Syntax highlighter for MkDocs and other tools. Pygments Docs
JupyterLab Ecosystem
βœ… ipykernel Interactive Computing Core dependency for running Jupyter Notebook kernels. IPyKernel Docs
βœ… ipywidgets Interactive Computing Interactive widgets for Jupyter. IPyWidgets Docs
βœ… jupyterlab Interactive Computing Web-based interface for interactive Python computing. JupyterLab Docs
βœ… jupyterlab-git Interactive Computing Git integration for JupyterLab. JupyterLab Git
⬜ jupyter-resource-usage Interactive Computing Monitor system resource usage during JupyterLab sessions. Resource Usage
⬜ jupyter_scheduler Interactive Computing Schedule and manage Jupyter Notebook execution tasks. Jupyter Scheduler
βœ”οΈ gunicorn Web Application Hosting Lightweight WSGI server for Python web applications. Gunicorn Docs
βœ”οΈ pandas Data Science Library for data manipulation and analysis. Pandas Docs
βœ”οΈ plotly Data Visualization Interactive and publication-quality data visualization. Plotly Docs
βœ”οΈ vizro Data Visualization Lightweight dashboards for Python data visualization. Vizro Docs

Directory StructureΒΆ

.
β”œβ”€β”€ Dockerfile                ## Main Dockerfile for building the image
β”œβ”€β”€ start.sh                  ## Startup script to initialize services
β”œβ”€β”€ starship.sh               ## Starship prompt configuration script
β”œβ”€β”€ .banner.sh                ## Custom banner for interactive sessions
β”œβ”€β”€ alias.sh                  ## Aliases for general use
β”œβ”€β”€ .bashrc                   ## Bash runtime configuration
β”œβ”€β”€ .config/
β”‚   └── starship.toml         ## Starship prompt configuration
β”œβ”€β”€ Taskfile.yaml             ## Taskfile for automation tasks