diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-09-12 23:06:12 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-09-12 23:07:43 +0200 |
commit | d236cd16a7173278ca69578d3e7ce4d1ce55e04c (patch) | |
tree | 80a8004b1d383e087745fdc8ecf231d3d370e0a5 /gnu/system | |
parent | 3d8424a5ad96452ae2bfd98d970f6047cc17b5fa (diff) | |
download | guix-d236cd16a7173278ca69578d3e7ce4d1ce55e04c.tar guix-d236cd16a7173278ca69578d3e7ce4d1ce55e04c.tar.gz |
linux-container: "run-container" scripts shows the container's PID.
* gnu/build/linux-container.scm (call-with-container): Add
#:process-spawned-hook and honor it.
* gnu/system/linux-container.scm (container-script)[script]:
Define 'explain' and pass it as #:process-spawned-hook'.
Diffstat (limited to 'gnu/system')
-rw-r--r-- | gnu/system/linux-container.scm | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index cca626be06..c6124cd223 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm @@ -171,11 +171,15 @@ that will be shared with the host system." (define script (with-imported-modules (source-module-closure '((guix build utils) - (gnu build linux-container))) + (gnu build linux-container) + (guix i18n) + (guix diagnostics))) #~(begin (use-modules (gnu build linux-container) (gnu system file-systems) ;spec->file-system (guix build utils) + (guix i18n) + (guix diagnostics) (srfi srfi-1)) (define file-systems @@ -187,6 +191,16 @@ that will be shared with the host system." fs))) '#$specs)) + (define (explain pid) + ;; XXX: We can't quite call 'bindtextdomain' so there's actually + ;; no i18n. + (info (G_ "system container is running as PID ~a~%") pid) + ;; XXX: Should we recommend 'guix container exec'? It's more + ;; verbose and doesn't bring much. + (info (G_ "Run 'sudo nsenter -a -t ~a' to get a shell into it.~%") + pid) + (newline (guix-warning-port))) + (call-with-container file-systems (lambda () (setenv "HOME" "/root") @@ -201,7 +215,8 @@ that will be shared with the host system." #:host-uids 65536 #:namespaces (if #$shared-network? (delq 'net %namespaces) - %namespaces))))) + %namespaces) + #:process-spawned-hook explain)))) (gexp->script "run-container" script))) |