From c203723e7ade20859288d2b9bdbb5f6fb50c0325 Mon Sep 17 00:00:00 2001 From: Vladimir Fokow <57260995+VladimirFokow@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:00:08 +0100 Subject: [PATCH] rough new faq section sourcing_when_container_starts TODO: check that the link `ch-run#environment-variables` works --- doc/faq.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/faq.rst b/doc/faq.rst index fb6cb16c6..fd0a9cb04 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -1361,6 +1361,28 @@ conversion. Important caveats include: in the :code:`user` namespace prior to Linux kernel `upstream 6.6 `_ (Oct 2023). +.. _faq_sourcing_when_container_starts: + +How do I source a file automatically when container starts? +----------------------------------------------------------- + +There are ways to have Bash source an arbitrary script at start-up +(`docs `_). + +For example :code:`ch-run ... -- bash --rcfile /my/start.sh` +will give you an interactive shell with :code:`/my/start.sh` sourced first. + +Or: :code:`ch-run ... -- bash --login` will give you an interactive login shell +and so it will source :code:`/etc/profile`. + +Finally, you can have a file :code:`$HOME/.bashrc` (where :code:`$HOME` is set by +default - is described `here `_), which bash will +source automatically with :code:`ch-run ... -- bash`. + +Alternatively, if you want the interactive Bash shell to source :code:`.bashrc` +of your host system, you can consider using :code:`ch-run --home`, which binds your +home directory into the container. + .. LocalWords: CAs SY Gutmann AUTH rHsFFqwwqh MrieaQ Za loc mpihello mvo du .. LocalWords: VirtualSize linuxcontainers jour uk lxd rwxr xr qq qqq drwxr