diff --git a/README.md b/README.md index bb03224..18c1f51 100644 --- a/README.md +++ b/README.md @@ -15,22 +15,23 @@ go install github.com/Samyak2/guntainer@latest ``` (ensure `GOBIN` is in path) -To run a container: + +Confirm that the installation succeeded. ``` -guntainer run ... +guntainer help ``` - - `archive_of_root_FS` is an archive (tar, zip, etc.) of a root filesystem which will be `chroot`ed into - - `command_to_run` is a program *inside* the container root FS that is run (note that `PATH` is not set unless you execute a shell) - - `args_for_command` are arguments for the program (everything after the `command_to_run` is passed directly to the program) - - -To build a new image, first make a [`Gunfile`](#building-images) and then use: +To run a container image, use the `run` subcommand. +See [here](#run-examples) for more information and examples. ``` -guntainer build Gunfile +guntainer run --help ``` -Where `Gunfile` can be replaced with the path to the Gunfile and `path_to_new_image` is the path where the generated image is saved (as a tar file) +To build a container image using a `Gunfile`, use the `build` subcommand. +See [here](#building-images) for more information and examples. +``` +guntainer build --help +``` ## Building images @@ -45,7 +46,7 @@ More examples can be found [here](./examples/). To build the image from [example_02](./examples/02_alpine_vim/), we can use: ``` -guntainer build examples/02_alpine_vim/Gunfile example_02.tar +guntainer build example_02.tar examples/02_alpine_vim/Gunfile ``` This will generate an `example_02.tar` which is the newly built image with `vim` installed. Run it using: diff --git a/cmd/build.go b/cmd/build.go index 815691d..71cfee3 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -6,11 +6,16 @@ import ( ) var buildCommand = &cobra.Command{ - Use: "build", + Use: "build [image-path] (Gunfile-path)", Short: "Build a new container from a Gunfile", - Long: "Executes the Gunfile to build a new container image.", + Long: `Executes the Gunfile to build a new container image. + + image-path: is where the resulting container image will be saved. + Gunfile-path: (optional) is the path to the Gunfile to use for building the image.`, + DisableFlagsInUseLine: true, + Args: cobra.RangeArgs(1, 2), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { if len(args) > 1 { core.Build(args[1], args[0]) } else { diff --git a/cmd/run.go b/cmd/run.go index 0a64ca9..8c56420 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -6,11 +6,18 @@ import ( ) var runCmd = &cobra.Command{ - Use: "run", + Use: "run [image-path] [command]", Short: "Run an existing container", - Long: "Run the archive of root FS as a container.", + Long: `Run the archive of root FS as a container. + + image-path: is an archive (tar, zip, etc.) of a root filesystem which will be 'chroot'ed into. + command: is a program *inside* the container root FS that is run (note that PATH is not set unless you execute a shell). + +Everything after the 'command' is passed as arguments directly to the command inside the container.`, + DisableFlagsInUseLine: true, + Args: cobra.MinimumNArgs(2), - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { core.Run(args[0], args[1], args[2:]) }, }