This commit will add the `--root/-r` flag to create,enter,list,rm,stop
commands. This will enable the use of podman/docker in root mode. This
is the preferred way over `sudo distrobox`.
Update man pages and docs accordingly.
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
The --dry-run switch for enter command fails with
```
DISTROBOX_ENTER_PATH=/usr/bin/distrobox-enter"'
++ set +o xtrace
/usr/bin/distrobox-enter: line 279: container_PATH: unbound variable
```
generate_command expects container_PATH to be declared, so move the
variable declaration slightly upper fixes the problem.
distrobox-init checks for three directories to make decisions based on
what package manager is being used in the following order:
/usr/lib/rpm/macros.d
/etc/dpkg/dpkg.cfg.d
/usr/share/libalpm/scripts
The problem is that a user might have the first two directories on Arch
Linux if they have installed the "rpm-tools" and "dpkg" packages
respectively. While that seems odd on the surface, these tools are
useful for building packages for "rpm" or "dpkg"-based distributions on
Arch Linux, such as the Linux kernel, which has "bindeb-pkg" and
"binrpm-pkg" targets to build a .deb and .rpm package respectively,
which does not require a Debian or Fedora host. As a result of the "rpm"
and "dpkg" directories being checked first, the third else if clause
never gets executed in the scenario described above.
Instead of making all these if statements mutually exclusive, allow them
all to be run, which should not impact anything during runtime, as only
one package manager will actually be used within the container. Arch
Linux explicitly notes this when installing the "dpkg" and "rpm-tools"
packages:
https://github.com/archlinux/svntogit-community/blob/55c1554978e24cdc5c53d1265a211e5c9dc72a0b/trunk/dpkg.installhttps://github.com/archlinux/svntogit-community/blob/13188cb24c4c2ee318f1efad3281e44c6516fde1/trunk/rpm-tools.install
While here, add a comment similar to the other checks.
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Introduce pacman pre and post transaction hooks, like with apt we can
now umount the read-only mounts from the host, and remount them at the
end of the transaction.
This ensures that we are less likely to find error in transactions not
expecting to find those paths as read-only.
Like with rpm and dpkg, we also overwrite the scripts at each init, so
that future changes in mounts will be reflected after a container stop
and restart.
Mounting also /run/systemd/system from host, will trick the systemd
package inside the container to think that the system is booted with
systemd (really just the presence of the path /run/systemd/system will
be sufficient).
Revert the mounting of this path, and document where this is needed.
This also fixes#222
include badge for latest available releases on various distros
thanks to all the package maintainers!
Include a warning for rootful docker usage as discussed on #201
* Fix compatibility with init containers
Fix#215
Right now systemd integration works only on docker, on podman it will
fail.
This is because docker daemon, running as root, has access to
/sys/fs/cgroup, while podman (rootless) does not.
Podman has a functionality to set up cgroups so that they work in
rootless mode as explained here: https://www.redhat.com/sysadmin/improved-systemd-podman
Right now the system is not triggered because it only checks if
entrypoint are `/sbin/init` or `/usr/bin/systemd`.
To fix this, let's force the use of systemd mode on podman if we're
using `--init`.
This problem went also undetected on the new CI as the `init` images are
tested as normal images. Let's also fix this and test create/enter on
init images using systemd commands.
* support environment variables to change defaults
* CI: test both podman and docker using new ENV variable
Implement use of environment variables to change defaults like:
- container manager
- default image to use
- default name to use
- interactivity
Variables will be respectively:
- DBX_CONTAINER_MANAGER
- DBX_CONTAINER_IMAGE
- DBX_CONTAINER_NAME
- DBX_NON_INTERACTIVE
This work opens also support for configuration rc-style files, in order of
importance:
- /usr/share/distrobox/distrobox.conf
- /etc/distrobox/distrobox.conf
- ${HOME}/.config/distrobox/distrobox.conf
- ${HOME}/.distroboxrc
The PATH fixes in 6b60c73999 use the
host's $PATH instead of the $PATH defined in the container. This
change fixes that by inspecting the container and parsing $PATH
out of its environment. The inspect was already being done so
this shouldn't be a signficiant performance impact. Future
features may desire further information out of the inspect
invocation and the parsing method can be extended.
The container's $PATH is merged with the host $PATH and the
standard set of binary paths as the existing logic uses.
Co-authored-by: Gerald Britton <gbritton@sekrit.org>
* Support LDAP/AD mail usernames
sometimes usernames can be in mail form or containing special chars,
this commit will force the creation of the user and group even if it has
invalid names.