runon/README.md

356 lines
9.1 KiB
Markdown
Raw Permalink Normal View History

2021-04-29 17:58:45 +02:00
RUNON - Run your commands in any systems
========================================
2021-04-30 20:32:20 +02:00
(c) 2021 Gilles Grandou <gilles@grandou.net>
licensed under GPL-2.0.
2021-04-29 17:58:45 +02:00
home: https://git.grandou.net/gilles/runon
2023-12-04 21:49:44 +01:00
Runon is a frontend to podman allowing to run seamlessly any application in
any linux based operating system, including graphical applications, while
keeping the host user environment.
the v1 legacy runon branch was based on docker. Current versions are now
relying on podman.
2021-04-29 17:58:45 +02:00
Quick HOWTO
-----------
$ grep ^PRETTY_NAME /etc/os-release
2023-12-04 21:49:44 +01:00
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
2021-04-29 17:58:45 +02:00
$ runon centos7 grep ^PRETTY_NAME /etc/os-release
PRETTY_NAME="CentOS Linux 7 (Core)"
$ runon ubuntu20.04 grep ^PRETTY_NAME /etc/os-release
2023-12-04 21:49:44 +01:00
PRETTY_NAME="Ubuntu 20.04.6 LTS"
2021-04-29 17:58:45 +02:00
$ runon debian9 grep ^PRETTY_NAME /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
2023-12-04 21:49:44 +01:00
$ runon rocky9 xterm
[xterm launched!]
2021-04-29 17:58:45 +02:00
Install
-------
Installation has been tested on:
2023-12-04 21:49:44 +01:00
* Debian 11 (bullseye)
* Debian 12 (bookworm)
* RockyLinux 9.3 (Blue Onyx)
However it should work straightforward on any equivalent system.
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
### Podman Install
If not already installed, just run as root the suitable command for your system:
apt install podman
dnf install podman
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
To check that podman is correctly installed, just try:
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
$ podman run -it hello-world
Resolved "hello-world" as an alias (/etc/containers/registries.conf.d/shortnames.conf)
Trying to pull docker.io/library/hello-world:latest...
Getting image source signatures
Copying blob 719385e32844 done
Copying config 9c7a54a9a4 done
Writing manifest to image destination
Storing signatures
Hello from Docker!
This message shows that your installation appears to be working correctly.
[...]
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
If your encounter an error like this one:
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
Error: writing blob: adding layer with blob "sha256:3331450fb84fde695e565405a554d5cf213a33826da197b29aabde08be012f8b": Error processing tar file(exit status 1): potentially insufficient UIDs or GIDs available in user namespace (requested 0:42 for /etc/gshadow): Check /etc/subuid and /etc/subgid: lchown /etc/gshadow: invalid argument
it's likely that your user account has been create a while ago on a legacy
distribution release and has no support for `subuid` and `subgid`. You can
fix it easily with these commands:
sudo usermod --add-subgids 10000-75535 $USER
sudo usermod --add-subuids 10000-75535 $USER
podman system migrate
podman pull
If you're running on a Debian system, there is a good explanation of the above problem in `/usr/share/doc/podman/README.Debian`.
2021-04-29 17:58:45 +02:00
### Python Dependencies
2023-12-04 21:49:44 +01:00
There is no specific dependency, you just need to insure to have:
* a Python release 3.6 or better
* the python `venv` module
* the python `pip` module
2021-04-30 20:21:55 +02:00
### manual install
2021-04-29 17:58:45 +02:00
cd <tools>
git clone https://git.grandou.net/gilles/runon
2023-12-04 21:49:44 +01:00
local install, in your `~/.local/bin`
2021-04-29 17:58:45 +02:00
2021-04-30 20:03:24 +02:00
cd <runon>
2023-12-04 21:49:44 +01:00
./install
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
If you plan to work `runon` development, you can
pass `--dev` to install links to your current git clone:
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
./install --dev
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
each user can have its own configuration in `~/.config/runon/runon.conf`.
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
You can keep your configuration in several places, the 1st one which is
find is used:
* `runon.yaml` in the current directory
* `.runon.yaml` in the current directory
* `~/.config/runon/runon.yaml`
* `~/.config/runon/runon.default.yaml`, the configuration file installed by
default
2021-04-29 17:58:45 +02:00
2021-04-30 20:03:24 +02:00
2021-04-30 20:21:55 +02:00
### uninstall
2021-04-30 20:03:24 +02:00
2023-12-04 21:49:44 +01:00
To uninstall, just run:
./uninstall
2021-04-30 20:03:24 +02:00
2021-04-29 17:58:45 +02:00
2021-04-30 20:21:55 +02:00
### some convenient links
2021-04-30 11:38:11 +02:00
you can create soft links to `runos` to simplify calls:
2023-12-04 21:49:44 +01:00
runos -l centos7
2021-04-30 11:38:11 +02:00
now calling `centos7 ...` is equivalent to call `runos centos7 ...`:
2023-12-04 21:49:44 +01:00
centos7 xterm
2021-04-30 11:38:11 +02:00
2021-04-29 17:58:45 +02:00
Usage
-----
With the default configuration, a seamless environment is set up,
allowing to transparently run commands in various environments, while
keeping:
2023-12-04 21:49:44 +01:00
* user environment (uid, gid, home directory, ...)
* password less sudo support
2021-04-29 17:58:45 +02:00
* X support to run graphical applications
2021-04-30 20:21:55 +02:00
### Basic usage
2021-04-29 17:58:45 +02:00
runon [options] <osname> <command>
runon -h
2021-04-30 20:21:55 +02:00
### available options
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
* `-v` verbose output, display information on the current startup step
2021-04-29 17:58:45 +02:00
* `-u` forces the container image to be updated, useful if the
distribution has been updated and you want to use it. Otherwise,
2021-04-30 20:35:17 +02:00
if a container has been already built, it will be used directly
without doing any network access.
2021-04-29 17:58:45 +02:00
* `-c <configfile>` uses a custom config file, useful to try new
distribution without breaking your running config.
2023-12-04 21:49:44 +01:00
* `-l` create an executable link with the `osname` name. you can after
run the command with `osname [...]` instead of `runos osname [...]`
### Listing available distributions:
Just run:
$ runon list
Available distributions:
centos7
debian10
debian11
debian12
debian9
rocky8
rocky9
ubuntu20.04
ubuntu22.04
This lists all `osname` present in your current configuration file.
### Editing configuration:
you can easily open the current configuration file with:
$ runon edit
If you open the `runon.default.yaml` file, take care to save your changes in
a new `runon.yaml` file to avoid the default one, which could be overwritten
next time you install or update `runon`.
2021-04-30 20:21:55 +02:00
### Interactive shell
2021-04-29 17:58:45 +02:00
Just run:
runon <osname>
while start an insteractive shell in the container system:
2023-12-04 21:49:44 +01:00
$ runon ubuntu22.04
(ubuntu22.04) gilles@host:~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
(ubuntu22.04) gilles@host:~$ xclock
2021-04-29 17:58:45 +02:00
^C
2023-12-04 21:49:44 +01:00
(ubuntu22.04) gilles@host:~$ exit
2021-04-29 17:58:45 +02:00
exit
2023-12-04 21:49:44 +01:00
To help differentiate the environment on are running on, you can add this
snippet to your `.bashrc`:
# container
if [ -n "$container" ]; then
PS1="($container) $PS1"
fi
This now displays your `runon` name on your bash prompt.
2021-04-29 17:58:45 +02:00
Configuration
-------------
2023-12-04 21:49:44 +01:00
Configuration is done in `runon.yaml` file, which describes supported
distribution in YAML format.
2021-04-29 17:58:45 +02:00
2021-04-30 20:21:55 +02:00
### Example config
2021-04-29 17:58:45 +02:00
```
2023-12-04 21:49:44 +01:00
rh_base: &rh_base
dockerfile:
- RUN dnf install -y sudo
- RUN echo "Defaults lecture = never" >> /etc/sudoers
- RUN echo "ALL ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
- RUN dnf group install -y "Development Tools"
pkginstall:
"RUN dnf install -y {}"
packages:
- xterm
- vim-X11
- git
- python3
- bash-completion
binds:
- /etc/timezone:ro
- /etc/localtime:ro
- "{home}"
environment:
- USER
- DISPLAY
- TERM
- container={osname}
centos7:
<<: *rh_base
image: docker.io/centos:7
dockerfile:
- RUN yum install -y sudo
- RUN echo "Defaults lecture = never" >> /etc/sudoers
- RUN echo "ALL ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
- RUN yum group install -y "Development Tools"
pkginstall:
"RUN yum install -y {}"
rocky8:
<<: *rh_base
image: docker.io/rockylinux:8
rocky9:
<<: *rh_base
image: docker.io/rockylinux:9
2021-04-29 17:58:45 +02:00
```
2023-12-04 21:49:44 +01:00
Each entry which contains an `image:` field defines a distribution which can
be used by runon. In the above example the other entries are used as templates
for real entries.
2021-04-29 17:58:45 +02:00
2021-04-30 20:21:55 +02:00
### Config entries
2021-04-29 17:58:45 +02:00
2023-12-04 21:49:44 +01:00
* `image` the base image used to build the container.
2021-04-29 17:58:45 +02:00
* `dockerfile` the base content of dockerfile which will be used to
generate the running environment. There is usually no need to diverge
2021-04-30 20:35:17 +02:00
from the ones given in example.
2021-04-29 17:58:45 +02:00
* `pkginstall` the dockerfile command used to install a package, likely
to be standard for all `deb` and `rpm` based distributions. In the
command `{}` is replaced by the package name.
* `packages` the list of packages to install. Feel free to add the ones
you need for your commands (likely news system libs, new tools, ...)
* `binds` the list of files and directories from the host system to
expose in the container system. you might want to add `/opt` or other
2021-04-30 20:35:17 +02:00
shared directories. See below for a description of `binds` entries
2021-04-29 17:58:45 +02:00
* `environment` the list of environment variables you want to pass or
set in the container system. See below for a description
2023-12-04 21:49:44 +01:00
Lines starting with `#` or are comments.
2021-04-29 17:58:45 +02:00
Some substitution happens upon reading the configuration:
2023-12-04 21:49:44 +01:00
* `{osname}` the executed distribution.
* `{user}` the current username
* `{uid}` the current UID
* `{home}` the user's home directory
2021-04-29 17:58:45 +02:00
2021-04-30 20:21:55 +02:00
### Binds
2021-04-29 17:58:45 +02:00
Each `binds` line can have one of the following formats:
<hostpath>
2021-04-30 20:35:17 +02:00
<hostpath>:<mode>
<hostpath>:<containerpath>
<hostpath>:<containerpath>:<mode>
2021-04-29 17:58:45 +02:00
with:
* `<hostpath>` is the filename or the dirname of the path you want
to expose
* `<containerpath>` is the pathname inside the container, by default
it's the same path.
* `<mode>` can be `rw`, read-write (by default), or `ro`, read-only.
2021-04-30 20:21:55 +02:00
### Environment
2021-04-29 17:58:45 +02:00
Each `environment` line define a Environment Variable which is set
in the container upon execution.
Each line can have one of the following formats:
<envvar>
<envvar>=<value>
If no value is given, the host value is passed into the container.