NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.8k forks source link

distrobox read-only filesystem error #253756

Open DrPyser opened 1 year ago

DrPyser commented 1 year ago

Describe the bug

When trying out a freshly installed distrobox, distrobox enter on any container fails. It seems to want to mount itself in the containers and fails because those binaries are in the read-only nix store.

 ❯ .nix-profile/bin/distrobox enter -v my-distrobox
+ '[' -z my-distrobox ']'
+ case "${container_manager}" in
+ command -v podman
+ command -v docker
+ container_manager=docker
+ command -v docker
+ '[' 1 -ne 0 ']'
+ container_manager='docker --log-level debug'
+ '[' 0 -ne 0 ']'
+ container_home=/home/drpyser
+ container_path=/run/wrappers/bin:/home/drpyser/.nix-profile/bin:/etc/profiles/per-user/drpyser/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/home/drpyser/bin:/home/drpyser/.local/bin
+ '[' 0 -ne 0 ']'
+ container_status=unknown
++ docker --log-level debug inspect --type container my-distrobox --format 'container_status={{.State.Status}};
        {{range .Config.Env}}{{if slice . 0 5 | eq "HOME="}}container_home={{slice . 5 | printf "%q"}};{{end}}{{end}}
        {{range .Config.Env}}{{if slice . 0 5 | eq "PATH="}}container_path={{slice . 5 | printf "%q"}}{{end}}{{end}}'
+ eval 'container_status=created;
        container_home="/home/drpyser";
        container_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"'
++ container_status=created
++ container_home=/home/drpyser
++ container_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ '[' created = unknown ']'
+ '[' created '!=' running ']'
+ printf 'Container %s is not running.\n' my-distrobox
Container my-distrobox is not running.
+ printf 'Starting container %s\n' my-distrobox
Starting container my-distrobox
+ printf 'run this command to follow along:\n\n'
run this command to follow along:

+ printf ' %s logs -f %s\n\n' 'docker --log-level debug' my-distrobox
 docker --log-level debug logs -f my-distrobox

++ date +%FT%T.%N%:z
+ log_timestamp=2023-09-06T20:56:33.%N%:z
+ docker --log-level debug start my-distrobox
Error response from daemon: error while creating mount source path '/run/current-system/sw/bin/distrobox-host-exec': mkdir /run/current-system/sw/bin/distrobox-host-exec: read-only file system
Error: failed to start containers: my-distrobox
+ rm -f /home/drpyser/.cache/.my-distrobox.fifo /home/drpyser/.cache/.my-distrobox.status

Steps To Reproduce

Steps to reproduce the behavior:

  1. install nixpkgs.distrobox (currently v1.5.0.2)
  2. distrobox create
  3. distrobox enter

Expected behavior

No read-only filesystem error. distrobox/docker should be able to mount those binaries read-only.

Notify maintainers

@AtilaSaraiva

Metadata


[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/c86v7bv01y5abwvqaal669hz7n99fcxm-nix-info
copying path '/nix/store/c86v7bv01y5abwvqaal669hz7n99fcxm-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.45, NixOS, 23.05 (Stoat), 23.05.20230819.4cdad15`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.0`
 - channels(root): `"nixos-21.11.337967.573603b7fdb, nixos-unstable"`
 - channels(drpyser): `"home-manager-21.11, nixos-21.11.337011.e7d63bd0d50, nixos-unstable-22.05pre363562.30d3d79b7d3, nixpkgs-22.05pre363562.30d3d79b7d3"`
 - nixpkgs: `/home/drpyser/.nix-defexpr/channels/nixpkgs````
DrPyser commented 1 year ago

When using --root option I don't get those errors and I can enter the containers, but I get flaky behavior on the first runs of the command:

 ❯ .nix-profile/bin/distrobox create -r --volume /tmp/.X11-unix:/tmp/.X11-unix --image quay.io/toolbx-images/archlinux-toolbox
Image quay.io/toolbx-images/archlinux-toolbox not found.
Do you want to pull the image now? [Y/n]: Y
Using default tag: latest
latest: Pulling from toolbx-images/archlinux-toolbox
7db0a613b381: Pull complete
0549be721c1e: Pull complete
f290565f6df2: Pull complete
935179f20949: Pull complete
2ae6caf89940: Pull complete
229389866c44: Pull complete
42444ba2ffcc: Pull complete
Digest: sha256:ba6d213de74d6573a70de0a74eb35ec65c3ee979a3c82c96bea775a3121dc9fe
Status: Downloaded newer image for quay.io/toolbx-images/archlinux-toolbox:latest
quay.io/toolbx-images/archlinux-toolbox:latest
Creating 'archlinux-toolbox' using image quay.io/toolbx-images/archlinux-toolbox         [ OK ]
Distrobox 'archlinux-toolbox' successfully created.
To enter, run:

distrobox enter --root archlinux-toolbox

❯ distrobox enter --root archlinux-toolbox
Container archlinux-toolbox is not running.
Starting container archlinux-toolbox
run this command to follow along:

 sudo docker logs -f archlinux-toolbox

 Starting container...                          ⏎

drpyser@drpyser-thinkpad[10.0.0.48] in flow.py  main 「𝚫 ✔ 📁 」
❌1 ❯ distrobox enter --root archlinux-toolbox
unable to find user drpyser: no matching entries in passwd file
126 ❯ distrobox enter --root archlinux-toolbox
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
drpyser@archlinux-toolbox ~/p/c/flow.py (main)>

So it takes some time/a few tries. But I can't still start X11 app from the container.

I-Want-ToBelieve commented 11 months ago

I've been trying to get systemd in the container to work without success, if you don't need systemd, using the command below should successfully create an archlinux

use podman, docker don't work!

~ via  v18.18.0 via 🐍 v3.9.18 
❯ cat ~/.config/distrobox/distrobox.conf
container_manager="podman"
container_additional_volumes="/etc/static/profiles/per-user:/etc/profiles/per-user:ro"

distrobox create --image quay.io/toolbx-images/archlinux-toolbox:latest --name archlinux --volume /etc/static/profiles/per-user:/etc/profiles/per-user:ro --verbose

with systemd

distrobox create --image archlinux:latest --name archlinux --additional-packages "systemd" --volume /etc/static/profiles/per-user:/etc/profiles/per-user:ro --init --verbose
distrobox enter archlinux

sudo systemctl status

ref: https://bbs.archlinux.org/viewtopic.php?id=234813