Skip to main content

A Python-based tool for converting Docker Compose configurations to Singularity Compose format

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dock2sing-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dock2sing-1.0.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file dock2sing-1.0.0.tar.gz.

File metadata

  • Download URL: dock2sing-1.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-200.fc41.x86_64

File hashes

Hashes for dock2sing-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8de066bef3fe9e58e252274d8e2a52d59d52a2db03b5247edd84452a43dedbeb
MD5 e5061d6695f76aa58c7d6dfd284716a3
BLAKE2b-256 9defcb3699e58061caa4774159b7be2efcce81d14eefd810383f10c3d476b0b0

See more details on using hashes here.

File details

Details for the file dock2sing-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dock2sing-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/6.13.7-200.fc41.x86_64

File hashes

Hashes for dock2sing-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca4791d3b65432f2a2883399808d73906a1f8a3c3bbc5e08ae0131602a14a349
MD5 967eb6ac46d002f24e7e2d57c139ad6c
BLAKE2b-256 899e66ea54858cf965dfbc6470902ca3beca61f8b172a7cc469e1d28b6f4a705

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page