Skip to content

compose-generator/diu

⚠️ This library is deprecated and is only used by Compose Generator until Docker Manifests are fully supported by the official Docker client. For that reason, please mind that this repository is not maintained anymore.

Docker Inspect Utils

GitHub release Go CI Go Report Card Codecov PRs Welcome

This Go library contains a set of useful features to parse internal Docker objects and put them into handelable objects or slices.

Note: This library is part of the Compose Generator project, but also can be used independently.

Installation

go get github.com/compose-generator/diu

Usage

Get manifest of remote image

Returns a struct with following structure: Structure

Example:

// You also can pass the image with a custom repository e.g.: ghcr.io/compose-generator/compose-generator
manifest, err := GetImageManifest("hello-world")
if err == nil {
    // Print layer count of hello-world image
    fmt.println("Number of layers: "+len(manifest.SchemaV2Manifest.Layers))
}

Get all volumes of local Docker instance

Returns a slice of structs with following structure: Structure

Example:

volumes, err := GetExistingVolumes()
if err == nil && len(volumes) > 0 {
    // Print layer count of hello-world image
    fmt.println("Name of first volume: "+volumes[0].Name)
}

Get all networks of local Docker instance

Returns a slice of structs with following structure: Structure

Example:

networks, err := GetExistingNetworks()
if err == nil && len(networks) > 0 {
    // Print layer count of hello-world image
    fmt.println("Name of first networks: "+networks[0].Name)
}

Contribute to the project

If you want to contribute to this project, please ensure you comply with the contribution guidelines.

© Marc Auberer 2021