libguestfs

Containerized libguestfs including virt-customize, guestfish, etc.

https://github.com/bkahlert/libguestfs

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.4%) to scientific vocabulary

Keywords

docker guestfish libguestfs shellscript virt-builder virt-customize

Keywords from Contributors

mesh interactive
Last synced: 6 months ago · JSON representation

Repository

Containerized libguestfs including virt-customize, guestfish, etc.

Basic Info
  • Host: GitHub
  • Owner: bkahlert
  • License: mit
  • Language: Shell
  • Default Branch: master
  • Homepage:
  • Size: 26.4 MB
Statistics
  • Stars: 25
  • Watchers: 2
  • Forks: 4
  • Open Issues: 5
  • Releases: 2
Topics
docker guestfish libguestfs shellscript virt-builder virt-customize
Created about 5 years ago · Last pushed about 2 years ago
Metadata Files
Readme Changelog Funding License Citation Codeowners

README.md

bkahlert/libguestfs Build Status Repository Size Repository Size

About

Containerized libguestfs including virt-customize, guestfish, etc.

Build locally

```shell git clone https://github.com/bkahlert/libguestfs.git cd libguestfs

Build image and output to docker (default)

docker buildx bake

Build multi-platform image

docker buildx bake image-all ```

Image

Following platforms for this image are available:

  • linux/amd64
  • linux/arm/v7
  • linux/arm64/v8
  • linux/ppc64le
  • linux/riscv64
  • linux/s390x

Usage

Interactively

```shell docker run -it --rm \ -v "$PWD":"$PWD" \ -w "$PWD" \ bkahlert/libguestfs:edge \ guestfish

add disk.img format:raw launch mount /dev/sda ./ ls / copy-out /boot data umount-all exit ```

Automatically

shell docker run -i --rm \ -v "$PWD":"$PWD" \ -w "$PWD" \ bkahlert/libguestfs:edge \ guestfish \ --ro \ --add disk.img format:raw \ --mount /dev/sda:/ \ <<COMMANDS ls / -copy-out /boot ./ umount-all exit COMMANDS

The command requires disk.img in this directory, mounts it with the guestfish tool and executes all guestfish commands enclosed by COMMANDS on the mounted disk.img.

In this case the directory /boot and its contents is copied to the current working directory.

Did you notice the leading dash in front of the copy-out command? Running guestfish non-interactively the first command that gives an error causes the whole shell to exit. By prefixing a command with - guestfish will not exit if an error is encountered.

If you prefix a command with ! (e.g. !id) the command will run on the host instead of the mounted guest. Since the libguestfs tools are containerized themselves, "host" signifies the containerized libguestfs hosting Ubuntu installation and not you actual OS.

Configuration

This image can be configured using the following options of which all but APP_USER and APP_GROUP exist as bothbuild argument and environment variable.
You should go for build arguments if you want to set custom defaults you don't intend to change (often). Environment variables will overrule any existing configuration on each container start.

  • APP_USER Name of the main user (default: libguestfs)
  • APP_GROUP Name of the main user's group (default: libguestfs)
  • DEBUG Whether to log debug information (default: 0)
  • TZ Timezone the container runs in (default: UTC)
  • LANG Language/locale to use (default: C.UTF-8)
  • PUID User ID of the libguestfs user (default: 1000)
  • PGID Group ID of the libguestfs group (default: 1000)
  • LIBGUESTFS_DEBUG Set this to 1 in order to enable massive amounts of debug messages. If you think there is some problem inside the libguestfs appliance, then you should use this option. (default: 0)
  • LIBGUESTFS_TRACE Set this to 1 and libguestfs will print out each command / API call in a format which is similar to guestfish commands. (default: 0)

```shell

Build single image with build argument TZ

docker buildx bake --set "*.args.TZ=$(date +"%Z")"

Build multi-platform image with build argument TZ

docker buildx bake image-all --set "*.args.TZ=$(date +"%Z")"

Start container with environment variable TZ

docker run --rm \ -e TZ="$(date +"%Z")" \ -v "$(pwd):$(pwd)" \ -w "$(pwd)" \ libguestfs:local ```

Testing

```shell git clone https://github.com/bkahlert/libguestfs.git cd libguestfs

Use Bats wrapper to run tests

curl -LfsS https://git.io/batsw | DOCKERBAKE="--set '*.tags=test'" bash -s -- --batsw:-e --batsw:BUILDTAG=test test ```

Bats Wrapper is a self-contained wrapper to run tests based on the Bash testing framework Bats.

To accelerate testing, the Bats Wrapper checks if any test is prefixed with a capital X and if so, only runs those tests.

Troubleshooting

If you run into problems, try running your intended steps interactively with verbose logging turned on:

shell docker run -it --rm \ -e "LIBGUESTFS_DEBUG=1" \ -e "LIBGUESTFS_TRACE=1" \ -v "$PWD":"$PWD" \ -w "$PWD" \ bkahlert/libguestfs:edge \ guestfish

To debug the image the following lines might become handy:

```shell

build local image with specified tag

docker buildx bake --set '*.tags=test'

copy something to test with

cp test/fixtures/tinycore.iso disk.img

start container interactively with a bash

docker run \ -e LIBGUESTFSDEBUG=1 \ -e LIBGUESTFSTRACE=1 \ -e DEBUG=1 \ -e TZ=CET \ -e PUID=68039910 \ -e PGID=584555228 \ -e TERM=xterm-256color \ -v /var/run/docker.sock:/var/run/docker.sock \ -v "$PWD":"$PWD" \ -w "$PWD" \ --interactive \ --tty \ --rm \ --entrypoint /bin/bash \ --name libguestfs-test \ test

fixes (normally performed by entrypoint.sh)

chmod 0644 /boot/vmlinuz* usermod -a -G kvm "$(whoami)"

run guestfish interactively

guestfish

or as root: (see entrypoint_user.sh for details)

LIBGUESTFS_BACKEND=direct guestfish

run guestfish using the original entrypoint

entrypoint.sh guestfish \ --ro \ --add disk.img format:raw \ --mount /dev/sda:/ \ <<COMMANDS ls / -copy-out /boot ./ umount-all exit COMMANDS ```

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by making a PayPal donation to ensure this journey continues indefinitely!

Thanks again for your support, it's much appreciated! :pray:

License

MIT. See LICENSE for more details.

Owner

  • Name: Björn Kahlert
  • Login: bkahlert
  • Kind: user
  • Location: Berlin, Germany

GitHub Events

Total
  • Watch event: 4
  • Fork event: 1
Last Year
  • Watch event: 4
  • Fork event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 75
  • Total Committers: 2
  • Avg Commits per committer: 37.5
  • Development Distribution Score (DDS): 0.147
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Björn Kahlert m****l@b****m 64
dependabot[bot] 4****] 11
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 2
  • Total pull requests: 25
  • Average time to close issues: 6 months
  • Average time to close pull requests: 4 months
  • Total issue authors: 2
  • Total pull request authors: 3
  • Average comments per issue: 3.5
  • Average comments per pull request: 0.4
  • Merged pull requests: 13
  • Bot issues: 0
  • Bot pull requests: 24
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • gaby (1)
  • hellt (1)
Pull Request Authors
  • dependabot[bot] (21)
  • github-actions[bot] (3)
  • tbeadle (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (21) github_actions (18) docker (3) recordr (3) docs (3) rec (3)

Dependencies

.github/workflows/build.yml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • bkahlert/bats-wrapper v0.1.4 composite
  • docker/bake-action v2 composite
  • docker/login-action v2 composite
  • docker/metadata-action v4 composite
  • docker/setup-buildx-action v2 composite
  • docker/setup-qemu-action v2 composite
  • softprops/action-gh-release v1 composite
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • bkahlert/recordr v0.2.2 composite
  • peter-evans/create-pull-request v5.0.0 composite
.github/workflows/test-report.yml actions
  • dorny/test-reporter v1 composite
Dockerfile docker
  • ubuntu 23.04 build