Skip to content

Conversation

@magland
Copy link
Owner

@magland magland commented Jul 24, 2025

@satra The below is AI-generated (as you can guess - but I reviewed it carefully) - but I'm human in this paragraph :). This adds a new persistent docker container mode, as you were describing in #5, but the old method of running commands in a container is still there - and is the default. We'll need to decide on whether to remove that or not given this persistent docker functionality.

Summary

This PR implements persistent Docker container functionality to address the issue where installations and changes made inside containers were lost between command executions. Previously, each execute_command call created a new temporary container with the --rm flag, causing any pip install or other modifications to be forgotten.

Changes

New Docker Management Commands

  • minicline docker start [image] [--name container-name] - Start a persistent Docker container
  • minicline docker stop <container-name> - Stop and remove a persistent container
  • minicline docker list - List all minicline containers
  • minicline perform-task --docker <container-name> - Execute tasks using an existing persistent container

Implementation Details

  1. New DockerManager class (minicline/docker_manager.py)

    • Manages persistent container lifecycle
    • Handles container creation, execution, and cleanup
    • Supports container existence checking and listing
  2. CLI Integration (minicline/cli.py)

    • Added docker command group with start, stop, and list subcommands
    • Added --docker option to perform-task command
    • Comprehensive help text and usage examples
  3. Core Functionality Updates

    • Modified perform_task() in core.py to accept docker_container parameter
    • Updated execute_command() in tools/execute_command.py to support persistent containers
    • Maintains full backward compatibility with existing temporary container behavior
  4. Documentation (README.md)

    • Added comprehensive Docker container management section
    • Included example workflows and usage patterns
    • Documented all new CLI options

Example Usage

# Start a persistent container
minicline docker start python:3.11
# Output: Container started successfully!
# Container name: minicline_persistent_1234567890

# Install packages (persists in container)
minicline perform-task --docker minicline_persistent_1234567890 "pip install pandas numpy matplotlib"

# Use installed packages in subsequent commands
minicline perform-task --docker minicline_persistent_1234567890 "make a sample analysis script using pandas and run it."

# List containers
minicline docker list

# Clean up when done
minicline docker stop minicline_persistent_1234567890

Benefits

  • State Persistence: Installations and file changes persist between command executions
  • Efficiency: Avoids repeated package installations and environment setup
  • Workflow Continuity: Enables complex multi-step tasks that build upon previous work
  • Backward Compatibility: Existing workflows continue to work unchanged
  • Container Management: Full lifecycle management with start, stop, and list operations


```bash
# Start a container with the default image (jupyter/scipy-notebook:latest)
minicline docker start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should perhaps add that this will mount the current working directory into the container.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the docs, comments, etc with this info.

@satra
Copy link
Contributor

satra commented Aug 2, 2025

@magland - the tool execute_command is not getting the persistent docker container. checking where it's failing to pass that on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants