diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-10-02 23:17:40 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-10-02 23:28:09 +0200 |
commit | 0f53c801b91919380a924b402d1ff822bb1dc6ea (patch) | |
tree | 428a6c2915344177a704d817796ffebdc9366536 /guix | |
parent | 8e1907a72430aa989125b053573ef0897c480697 (diff) |
environment: Provide /etc/hosts in containers without '--network'.
Fixes <https://bugs.gnu.org/43762>.
* guix/scripts/environment.scm (launch-environment/container): Create
/etc/hosts when NETWORK? is false.
* tests/guix-environment-container.sh: Add "localhost" resolution test.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/scripts/environment.scm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index e2e481dd02..9698111cd2 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -549,6 +549,13 @@ WHILE-LIST." (write-passwd (list passwd)) (write-group groups) + (unless network? + ;; When isolated from the network, provide a minimal /etc/hosts + ;; to resolve "localhost". + (call-with-output-file "/etc/hosts" + (lambda (port) + (display "127.0.0.1 localhost\n" port)))) + ;; For convenience, start in the user's current working ;; directory or, if unmapped, the home directory. (chdir (if map-cwd? |