Skip to main content

Dock2Sing

A Python-based tool for converting Docker Compose configurations to Singularity Compose format, with built-in validation and guidance.

Overview

This tool helps users migrate their Docker Compose configurations to Singularity Compose format, which is particularly useful in HPC (High-Performance Computing) environments where Singularity is the preferred container runtime. The tool includes a validation component that helps identify potential issues and provides guidance for the conversion process.

Features

  • Converts Docker Compose services to Singularity instances
  • Handles key Docker Compose features:
    • Container images
    • Volume mounts
    • Environment variables
    • Port mappings
    • Working directories
    • Service dependencies
  • Provides detailed validation of converted configurations
  • Offers guidance for handling unsupported features
  • Includes colored terminal output for better readability
  • Supports comparison with original Docker Compose file

Requirements

  • Python 3.12 or higher
  • Poetry for dependency management
  • Singularity installed on the target system

Installation

  1. Clone the repository:
git clone https://github.com/labadorf/dock2sing.git
cd dock2sing
  1. Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -
  1. Install the project and its dependencies:
poetry install

Usage

Converting Docker Compose to Singularity Compose

poetry run dock2sing docker-compose.yml [-o singularity-compose.yml]

Options:

  • docker-compose.yml: Path to your Docker Compose file (required)
  • -o, --output: Path for the output Singularity Compose file (optional, defaults to singularity-compose.yml)

Validating Singularity Compose Configuration

poetry run validate-singularity singularity-compose.yml [-d docker-compose.yml]

Options:

  • singularity-compose.yml: Path to your Singularity Compose file (required)
  • -d, --docker: Path to the original Docker Compose file for comparison (optional)

Development

This project uses several development tools to maintain code quality:

  • pytest for testing
  • black for code formatting
  • isort for import sorting
  • flake8 for linting

To set up the development environment:

poetry install --with dev

To run tests:

poetry run pytest

To format code:

poetry run black .
poetry run isort .

Important Notes

Feature Compatibility

Some Docker features have different implementations or limitations in Singularity:

  1. Networking:

    • Singularity networking works differently from Docker
    • Custom networks need manual configuration
    • Port mappings may require additional setup
  2. Volumes:

    • Named volumes need manual configuration
    • Volume paths should be absolute
    • Bind mounts work differently in Singularity
  3. User Permissions:

    • Singularity containers run with user permissions by default
    • Root access requires special configuration
    • User namespace handling differs from Docker
  4. Unsupported Features:

    • Healthchecks
    • Secrets
    • Configs
    • Deploy configurations

Best Practices

  1. Always validate your converted configuration
  2. Test each container individually before running the full setup
  3. Review the validation warnings and address them appropriately
  4. Consider using Singularity definition files for custom container builds
  5. Use absolute paths for volume mounts
  6. Test thoroughly in your target environment

Example

Input Docker Compose File

version: '3'
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./data:/usr/share/nginx/html
    environment:
      - DEBUG=1

Output Singularity Compose File

version: '1.0'
instances:
  web:
    container: docker://nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./data:/usr/share/nginx/html
    environment:
      DEBUG: "1"

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Docker Compose team for the original specification
  • Singularity team for the container runtime
  • Contributors and users of this tool

Metadata

Release files for dock2sing 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dock2sing 1.0.0
File Size Uploaded
dock2sing-1.0.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dock2sing 1.0.0
File Interpreter ABI Platform
dock2sing-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / dock2sing-1.0.0.tar.gz

Download URL dock2sing-1.0.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8de066bef3fe9e58e252274d8e2a52d59d52a2db03b5247edd84452a43dedbeb
BLAKE2b-256 checksum
How to use checksums
9defcb3699e58061caa4774159b7be2efcce81d14eefd810383f10c3d476b0b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-200.fc41.x86_64

Release files / dock2sing-1.0.0-py3-none-any.whl

Download URL dock2sing-1.0.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca4791d3b65432f2a2883399808d73906a1f8a3c3bbc5e08ae0131602a14a349
BLAKE2b-256 checksum
How to use checksums
899e66ea54858cf965dfbc6470902ca3beca61f8b172a7cc469e1d28b6f4a705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-200.fc41.x86_64

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page