clearly convert¶
Convert an image from one format to another.
Synopsis¶
$ clearly convert [-i FMT] [-o FMT] [OPTION ...] IN OUT
Description¶
Copy image IN to OUT and convert its format. Replace
OUT if it already exists, unless --no-clobber is specified. It
is an error if IN and OUT have the same format; use the
format’s own tools for that case.
clearly run can run container images that are plain directories or
(optionally) SquashFS archives. However, images can take on a variety of other
formats as well. The main purpose of this tool is to make images in those
other formats available to clearly run.
For best performance, clearly convert should be invoked only once,
producing the final format actually needed.
INDescriptor for the input image. For image builders, this is an image reference; otherwise, it’s a filesystem path.
OUTDescriptor for the output image.
-h,--helpPrint help and exit.
-i,--in-fmt FMTInput image format is
FMT. If omitted, inferred as described below.-n,--dry-runDon’t read the input or write the output. Useful for testing format inference.
--no-clobberError if
OUTalready exists, rather than replacing it.--no-xattrsIgnore xattrs and ACLs when converting. Overrides
$CLEARLY_XATTRS.-o,--out-fmt FMTOutput image format is
FMT; inferred if omitted.-q,--quietBe quieter; can be repeated. Incompatible with
-v. See the FAQ entry on verbosity for details.-s,--storage DIRSet the storage directory. Equivalent to the same option for
clearly image(1)andclearly run(1).--tmp DIRA sub-directory for temporary storage is created in
DIRand removed at the end of a successful conversion. If this script crashes or errors out, the temporary directory is left behind to assist in debugging. Storage may be needed up to twice the uncompressed size of the image, depending on the input and output formats. Default:$TMPDIRif specified; otherwise/var/tmp.-v,--verbosePrint extra chatter. Can be repeated.
--xattrsPreserve xattrs and ACLs when converting.
Image formats¶
clearly convert knows about these values of FMT:
clearly imageInternal storage for Clearly’s unprivileged image builder (Dockerfile interpreter)
clearly image.dirOrdinary filesystem directory (i.e., not a mount point) containing an unpacked image. Output directories that already exist are replaced if they look like an image. If the output directory is empty, the conversion should use the directory without overwriting it. If the directory doesn’t look like an image and isn’t empty, exit with an error.
dockerInternal storage for Docker.
podmanInternal storage for Podman.
squashSquashFS filesystem archive containing the flattened image. SquashFS archives are much like tar archives but are mountable, including by
clearly run's internal SquashFUSE mounting. Most systems have at least the SquashFS-Tools installed which allows unpacking into a directory, just like tar. Due to this greater flexibility, SquashFS is preferred to tar.Note: Conversions to and from SquashFS are quite noisy due to the verbosity of the underlying
mksquashfs(1)andunsquashfs(1)tools.tarTar archive containing the flattened image with no layer sub-archives; i.e., the output of
docker exportworks but the output ofdocker savedoes not. Output tarballs are always gzipped and must end in.tar.gz; input tarballs can be any compression acceptable totar(1).
All of these are local formats; clearly convert does not know how to push
or pull images.
Format inference¶
clearly convert tries to save typing by guessing formats when they are
reasonably clear. This is done against filenames, rather than file contents,
so the rules are the same for output descriptors that do not yet exist.
Format inference is done for both IN and OUT. The first
matching glob below yields the inferred format. Paths need not exist in the
filesystem.
*.sqfs,*.squash,*.squashfs: SquashFS.
*.tar,*.t?z,*.tar.?,*.tar.??: Tarball.
/*,./*, i.e. absolute path or relative path with explicit dot: Directory.If clearly image is installed:
clearly imageinternal storage.If Podman is installed: Podman internal storage.
If Docker is installed: Docker internal storage.
Otherwise: No format inference.
Examples¶
Typical build-to-run sequence for image foo/bar using clearly run's
internal SquashFUSE code, inferring the output format:
$ sudo docker build -t foo/bar -f Dockerfile .
[...]
$ clearly convert foo/bar:latest /var/tmp/foobar.sqfs
input: docker foo/bar:latest
output: squashfs /var/tmp/foobar.sqfs
copying ...
done
$ clearly run /var/tmp/foobar.sqfs -- echo hello
hello
Same conversion, but no format inference:
$ clearly convert -i clearly image -o squash foo/bar:latest /var/tmp/foobar.sqfs
input: docker foo/bar:latest
output: squashfs /var/tmp/foobar.sqfs
copying ...
done