This repo reflects my personal approach/setup for distrobox & podman and tries to automate this process as much as possible.
All images stem from the same base (Containerfile.base
) which initializes
- the distribution toolbx/arch-toolbox:latest
- Base packages
- To keep the home directories of each container separated from the hosts home I prefer to set a directory for it. This can be easily done by setting the
DBX_CONTAINER_HOME_PREFIX
(this is done automatically when running thecreate.sh
script) environment variable. - Access to a git repository/needed ssh keys (see) has to be provided before running the container specific init scripts. Otherwise some settings/environment variables are missing - this can be fixed by re-running the init script with access to the repository.
Most of the process is automated by executing the ./build.sh
which builds all the images and then creates the defined containers according to the distrobox.ini
.
The following steps describe the steps which you could go trhough manually.
It is recommended to first build the base image and the subsequently build all other child images.
podman build -t $IMAGE_NAME -f Containerfile
This will create the specified image with the defined path for the home directory and the hosts ssh authentication agent is passed into the container.
distrobox create --name $CONTAINER_NAME --image localhost/$IMAGE_NAME --home ~/Distrobox/$CONTAINER_NAME --volume $SSH_AUTH_SOCK:$SSH_AUTH_SOCK:Z --additional-flags "--env SSH_AUTH_SOCK:{$SSH_AUTH_SOCK}" --volume ~/Dev::rw
distrobox enter $CONTAINER_NAME
To complete the setup you have to run the init.sh
script from inside of the container and afterwards you have to exit and enter it again.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/DrStrangeloovee/my-distroboxes/master/init.sh)"
I find it useful to be able to be able to use podman from the host system - wheter or not you need that is up to you and differs from each use case. Feel free to change this as needed.
What you will often see is something like the following:
RUN ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/podman && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/flatpak && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/podman && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/rpm-ostree && \
ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/transactional-update
Consult the distrobox documentation for more info.
To simplify ssh access the hosts ssh-agent is passed into the container by
- Mounting the socket into it.
- Setting the $SSH_AUTH_SOCKET variable. at the creation of the container. This gives you the benefit of storing your keys on the host and make them available to all containers at once - even works through KeePass with its ssh-agent integration.
distrobox create --name $CONTAINER_NAME --image localhost/$IMAGE_NAME --home ~/Distrobox/$CONTAINER_NAME --volume $SSH_AUTH_SOCK:$SSH_AUTH_SOCK:Z --additional-flags "--env SSH_AUTH_SOCK:{$SSH_AUTH_SOCK}"
Note: Check that the container user (the one distrobox creates for you) shares the same UID - otherwise you will almost certainly run into issues. (TODO: document/find solution for this)
The following is a list of open improvements which further automate the setup:
- If the user enters the container the first time he should get a message that the container can be setup by running the
init.sh
or it could be baked in the container image. - Add chezmoi machine specific dotfiles
- Setup gitconfig (via chezmoi?)
- For fh-b3-ai the rye shim (mkdir $ZSH_CUSTOM/plugins/rye rye self completion -s zsh > $ZSH_CUSTOM/plugins/rye/_rye) can't be set because the $ZSH_CUSTOM variable is not available - this has to be run under an active zsh session.
- Setup zsh completions 4.1. ripgrep
- Automate VSCode plugin install/setup