Support for additional volumes and flags (#136)

* create/enter: support for additional volumes and flags
* docs: update docs and man pages to include new flags
This commit is contained in:
Luca Di Maio
2022-01-22 12:38:53 +01:00
committed by GitHub
parent d4c1e07d91
commit e3b1252e7c
7 changed files with 193 additions and 0 deletions
+28
View File
@@ -10,6 +10,8 @@ Usage:
distrobox-create --image registry.fedoraproject.org/fedora-toolbox:35 --name fedora-toolbox-35
distrobox-create --clone fedora-toolbox-35 --name fedora-toolbox-35-copy
distrobox-create --image alpine my-alpine-container
distrobox create --image fedora:35 --name test --volume /opt/my-dir:/usr/local/my-dir:rw --additional-flags "--pids-limit -1"
distrobox create --image fedora:35 --name test--additional-flags "--env MY_VAR-value"
You can also use environment variables to specify container name and image
@@ -30,6 +32,32 @@ Options:
this will be useful to either rename an existing distrobox or have multiple copies
of the same environment.
--home/-H select a custom HOME directory for the container. Useful to avoid host's home littering with temp files.
--volume additional volumes to add to the container
--additional-flags/-a: additional flags to pass to the container manager command
--help/-h: show this message
--verbose/-v: show more verbosity
--version/-V: show version
The `--additional-flags` or `-a` is useful to modify defaults in the container creations.
For example:
distrobox create -i docker.io/library/archlinux -n dev-arch
podman container inspect dev-arch | jq '.[0].HostConfig.PidsLimit'
2048
distrobox rm -f dev-arch
distrobox create -i docker.io/library/archlinux -n dev-arch --volume $CBL_TC:/tc --additional-flags "--pids-limit -1"
podman container inspect dev-arch | jq '.[0].HostConfig,.PidsLimit'
0
Additional volumes can be specified using the `--volume` flag. This flag follows the same standard as `docker` and `podman`
to specify the mount point so `--volume SOURCE_PATH:DEST_PATH:MODE`.
distrobox create --image docker.io/library/archlinux --name dev-arch --volume /usr/share/:/var/test:ro
During container creation, it is possible to specify (using the additional-flags) some environment variables that will
persist in the container and be independent from your environment:
distrobox create --image fedora:35 --name test--additional-flags "--env MY_VAR-value"
+16
View File
@@ -10,6 +10,9 @@ Usage:
distrobox-enter --name fedora-toolbox-35 -- bash -l
distrobox-enter my-alpine-container -- sh -l
distrobox-enter --additional-flags "--preserve-fds" --name test -- bash -l
distrobox-enter --additional-flags "--env MY_VAR=value" --name test -- bash -l
MY_VAR=value distrobox-enter --additional-flags "--preserve-fds" --name test -- bash -l
Supported environment variables:
@@ -20,8 +23,21 @@ Options:
--name/-n: name for the distrobox default: fedora-toolbox-35
--/-e: end arguments execute the rest as command to execute at login default: bash -l
--headless/-H: do not instantiate a tty
--additional-flags/-a: additional flags to pass to the container manager command
--help/-h: show this message
--verbose/-v: show more verbosity
--version/-V: show version
This is used to enter the distrobox itself. Personally, I just create multiple profiles in my `gnome-terminal` to have multiple distros accessible.
The `--additional-flags` or `-a` is useful to modify default command when executing in the container.
For example:
distrobox enter -n dev-arch --additional-flags "--env my_var=test" -- printenv &| grep my_var
my_var=test
This is possible also using normal env variables:
my_var=test distrobox enter -n dev-arch --additional-flags -- printenv &| grep my_var
my_var=test