unregistry

repository·main·Indexed 26 days ago

https://github.com/psviderski/unregistry

A lightweight OCI-compliant container image registry that stores and serves images directly from the Docker daemon's storage. It includes the docker-pussh CLI plugin to transfer images to remote servers over SSH by transferring only missing layers, avoiding the overhead of full image save/load or external registries.

Tokens
1.9K
Snippets
3
Records
15
Agent score
87%

What's inside unregistry

  1. Install the docker-pussh CLI plugin

    main

    Unregistry provides the docker-pussh plugin, which allows you to push Docker images directly to remote servers over SSH. Installation methods vary by platform.

    macOS/Linux via Homebrew

    brew install psviderski/tap/docker-pussh
    
    # Create the symlink to enable the 'docker pussh' command
    mkdir -p ~/.docker/cli-plugins
    ln -sf $(brew --prefix)/bin/docker-pussh ~/.docker/cli-plugins/docker-pussh

    macOS/Linux via direct download

    mkdir -p ~/.docker/cli-plugins
    
    # Download version 0.4.3
    curl -sSL https://raw.githubusercontent.com/psviderski/unregistry/v0.4.3/docker-pussh \
      -o ~/.docker/cli-plugins/docker-pussh
    
    chmod +x ~/.docker/cli-plugins/docker-pussh

    Debian

    Install via the unofficial repository maintained by @dariogriffo:

    sudo install -d -m 0755 /etc/apt/keyrings
    curl -fsSL https://deb.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/keyrings/deb.griffo.io.gpg
    echo "deb [signed-by=/etc/apt/keyrings/deb.griffo.io.gpg] https://deb.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | sudo tee /etc/apt/sources.list.d/deb.griffo.io.list
    sudo apt update
    sudo apt install -y unregistry docker-pussh
  2. Push Docker images to a remote server with docker pussh

    main

    Use the docker pussh command to transfer images directly to a remote Docker daemon over SSH. It only transfers missing layers, making it efficient like rsync for images.

    Requirements for Remote Server:

    • Docker must be installed and running.
    • The SSH user must have permissions to run docker commands (either root or in the docker group).
    • If sudo is required, the user must be able to run sudo docker without a password prompt.
    • The server needs internet access to pull ghcr.io/psviderski/unregistry:latest on the first use, or you must preload the image manually.

    Basic Usage:

    docker pussh myapp:latest user@server.example.com
    docker pussh myapp:latest user@server.example.com
  3. Use the unregistry CLI

    main

    The unregistry command starts a lightweight OCI-compliant container registry that uses your local Docker (containerd) image store as a backend. This allows you to push and pull images using standard registry APIs without needing an external storage backend like Docker Hub.

    Key Use Cases:

    • Pushing built images directly to remote servers.
    • Serving images from a single node to multiple nodes in a cluster.
    • Distributing images in air-gapped environments.
    • Local development and testing workflows.
    • Exposing pre-loaded images via a standard registry API.
  4. Manage images in containerd storage

    main

    If you are not using the Docker 'containerd image store' (the default behavior), images pushed via unregistry are stored in containerd and then pulled again into the classic Docker store. This results in duplicate storage.

    To manually manage or remove these unmanaged images in containerd, use the ctr tool:

    • List images: sudo ctr -n moby images ls
    • Remove image: sudo ctr -n moby images rm <image>
  5. Run unregistry as a standalone local registry

    main

    You can run the unregistry container locally to act as a lightweight registry. This is useful for testing or local development without a full registry service.

    Note: The container requires access to the containerd socket at /run/containerd/containerd.sock and must run as root.

    # Run unregistry locally on port 5000
    docker run -d -p 5000:5000 --name unregistry \
      -v /run/containerd/containerd.sock:/run/containerd/containerd.sock \
      ghcr.io/psviderski/unregistry
    
    # Tag and push to it
    docker tag myapp:latest localhost:5000/myapp:latest
    docker push localhost:5000/myapp:latest
  6. Configure docker pussh with SSH options

    main

    The docker pussh command supports various SSH configurations to handle different authentication and connection scenarios.

    • SSH Key Authentication: Use -i to specify a private key if it's not in your SSH agent.
    • Custom Port: Use the user@server:port syntax.
    • Custom SSH Config: Use -F to specify a specific SSH configuration file.
    • SSH Config Host: You can use host aliases defined in your ~/.ssh/config.
  7. Push multi-platform images and custom unregistry versions

    main

    For advanced deployment scenarios, you can specify target platforms or override the unregistry image version used on the remote host.

    Note: To support multi-platform images, your local Docker must have the containerd image store enabled.

    • Target Platform: Use --platform to push a specific architecture.
    • Custom Unregistry Image: Use the UNREGISTRY_IMAGE environment variable to specify which version of the unregistry container to run on the remote host.
  8. Initialize a registry with NewRegistry

    main

    Use NewRegistry to create a new Registry instance. This function configures the global logrus logger based on the provided Config and initializes the underlying distribution application with a filesystem storage driver and containerd middleware.

    Configuration Requirements:

    • LogLevel: A valid logrus level (e.g., info, debug).
    • LogFormatter: Must be either "json" or "text".
    • Addr: The network address for the HTTP server.
    • ContainerdNamespace: The namespace for the containerd middleware.
    • ContainerdSock: The path to the containerd socket.
  9. Start the registry server with ListenAndServe

    main
    The ListenAndServe method starts the HTTP server associated with the Registry instance. It will block until the server is closed or an error occurs. It ignores http.ErrServerClosed errors, treating them as a normal part of the shutdown process.