Skip to content

ZeroNihl/containers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Docker Container Management Tool

A Python-based CLI tool for managing Docker development containers with consistent environments and configurations.

Features

  • Create, start, stop, and manage Docker containers
  • Workspace mounting and port forwarding
  • User management with non-root execution
  • Cache management and container rebuilding
  • Environment variable configuration
  • Startup script execution

Prerequisites

  • Python 3.6+
  • Docker installed and running
  • Proper file structure:
    root/
    ├── drun/
    │   └── templates/
    │       └── Dockerfile.template
    └── projects/
        └── [container-name]/
            └── Dockerfile
    

Usage

python3 script.py <operation> <container-name> [options]

Operations

  • create: Create and start new container
  • start: Start existing container
  • stop: Stop running container
  • restart: Restart container
  • clean: Restart with cache clear
  • reset: Remove and recreate container
  • nuke: Full rebuild from scratch

Options

  • --username: Container username (env: DOCKER_USER)
  • --password: User password (env: DOCKER_PASS)
  • --workspace: Local workspace path (env: DOCKER_WORKSPACE)
  • --startup-script: Startup script path (env: DOCKER_STARTUP)
  • --ports: Port forwards as host:container (env: DOCKER_PORTS)
  • --root: Run as root user (env: DOCKER_ROOT)
  • --debug: Debug level (0-4)

Environment Variables

  • DOCKER_USER: Default username (default: "developer")
  • DOCKER_PASS: Default password (default: "password")
  • DOCKER_WORKSPACE: Default workspace path (default: "./workspace")
  • DOCKER_ROOT: Run as root by default (default: "0")
  • DOCKER_PORTS: Default port mappings (format: "host1:container1,host2:container2")
  • DOCKER_STARTUP: Default startup script path
  • DOCKER_DEBUG: Default debug level (default: "0")

Examples

  1. Create a new container:
python3 script.py create mydev --workspace ~/projects/mydev --ports 8080:80 3000:3000
  1. Start existing container:
python3 script.py start mydev
  1. Reset with custom user:
python3 script.py reset mydev --username devuser --password devpass
  1. Clean restart with startup script:
python3 script.py clean mydev --startup-script init.sh

Debugging

Use the --debug flag with levels 0-4 for increasing verbosity:

python3 script.py create mydev --debug 2

Project Structure

  • Container configurations are stored in projects/<container-name>/
  • Default Dockerfile template in drun/templates/Dockerfile.template
  • Workspace is mounted at /home/<username>/workspace
  • Workspace mounting persists across container starts/stops

Error Handling

  • Validates container existence before operations
  • Reports build and execution errors
  • Handles port conflicts and permission issues
  • Provides debug output for troubleshooting

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages