Skip to content

Conversation

@yuzhichang
Copy link
Contributor

Add Pull Mode Support to docker-pussh

This PR adds pull mode functionality to docker-pussh, enabling bidirectional image transfer between local and remote Docker daemons.

🚀 New Features

Pull Mode: Download Docker images from remote hosts to local

  • Syntax: ./docker-pussh [USER@]HOST[:PORT] IMAGE[:TAG]
  • Auto-detection: Automatically detects pull vs push mode based on argument patterns
  • Same options: Supports all existing options (--platform, -i/--ssh-key, etc.)

📋 Usage Examples

# Push mode (existing functionality)
./docker-pussh ubuntu:20.04 [email protected]
./docker-pussh myapp:latest user@host:2222 -i ~/.ssh/id_rsa

# Pull mode (new functionality) 
./docker-pussh [email protected] ubuntu:20.04
./docker-pussh user@host:2222 myapp:latest -i ~/.ssh/id_rsa

🔧 Implementation Details

  • Smart Mode Detection: Automatically determines operation mode by analyzing first argument pattern (SSH address vs image name)
  • Reverse Flow: In pull mode, the remote image is pushed to unregistry on remote host, then pulled to local Docker
  • Error Handling: Comprehensive error checking including remote image existence validation
  • Resource Cleanup: Proper cleanup of temporary tags and containers on both local and remote hosts
  • Retry Logic: Same robust retry mechanism as push mode for network reliability

✅ Quality Assurance

  • Shellcheck Clean: All code passes strict shellcheck validation with --enable=all
  • Backward Compatible: Existing push mode functionality remains unchanged
  • Updated Documentation: Enhanced help text with clear examples for both modes
  • Consistent UX: Same command-line interface patterns and error messages

🎯 Benefits

  • Bidirectional Transfer: Complete solution for Docker image synchronization
  • No Breaking Changes: Existing scripts and workflows continue to work
  • Intuitive Syntax: Natural argument order that matches user expectations
  • Feature Parity: Pull mode supports all push mode capabilities (platform selection, SSH keys, etc.)

This enhancement makes docker-pussh a complete solution for Docker image transfer in both directions while maintaining the tool's simplicity and reliability.

📝 Technical Changes

Mode Detection Logic

The tool now automatically detects the operation mode by analyzing the first argument:

  • If it matches SSH address patterns (contains @, IP address, or hostname without :), it's pull mode
  • Otherwise, it's push mode (image name with optional tag)

Pull Mode Workflow

  1. Connect to remote host via SSH
  2. Verify remote image exists
  3. Start unregistry container on remote host
  4. Forward local port to remote unregistry
  5. Tag and push remote image to unregistry
  6. Pull image from unregistry to local Docker
  7. Retag with desired local name
  8. Clean up temporary resources

Updated Help Text

The usage information now clearly shows both modes with comprehensive examples for different scenarios including platform selection and SSH key usage.

@yuzhichang yuzhichang changed the title Added pull mode support feat: Added pull mode support Jul 23, 2025
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.

1 participant