diff --git a/README.md b/README.md index 22a763a..78c0551 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ ecr [OPTIONS] [-- COMMAND...] | `--kernel[=PATH]` | Boot with QEMU system emulation. Downloads Alpine's default kernel if no `=PATH` given (`linux-virt`, or `linux-lts` on riscv64 where the virt flavor is not built) | | `-m, --memory ` | Memory for QEMU VM (default: 2G, only with `--kernel`) | +The command starts in the directory mapped from your current one: `/root/` with the default `--bind`, `/mnt/` with `--bind-rw`. With `--no-bind` (or when the current directory is not mapped) it starts in `/root`. + ## Examples ```sh @@ -101,6 +103,7 @@ ecr debian ecr alpine -- sh -c 'apk add curl && curl -s https://example.com' # Work on your project inside Ubuntu — changes are visible on the host +# (the shell starts in /mnt/myapp, where the project is mounted) ecr ubuntu --bind-rw ~/projects/myapp # Native-compile for ARM64 through emulation (requires QEMU binfmt_misc) diff --git a/SPEC.md b/SPEC.md index 39785ed..38ec99d 100644 --- a/SPEC.md +++ b/SPEC.md @@ -229,7 +229,7 @@ The CLI delegates to the library; the namespace-mode flow is: 7. Set up mounts: /proc, /sys (ro), /dev, /dev/pts 8. Apply bind targets: overlays (ro) and bind mounts (rw) 9. Write /etc/resolv.conf with DNS servers -10. Set the working directory +10. Set the working directory to the target where the current directory is mapped (`/root/`, or `/mnt/` with `--bind-rw`); the library default applies when it is not mapped 11. Exec shell or command in chroot with the composed envp 12. On exit, clean up the temporary directory; propagate the exit code @@ -364,7 +364,7 @@ The rootfs directory is converted to an uncompressed CPIO archive (newc format) ### Overlay Mount (Default) -By default, the current working directory is mounted as an overlay filesystem at `/root/` inside the chroot, where `` is the name of the current directory. +By default, the current working directory is mounted as an overlay filesystem at `/root/` inside the chroot, where `` is the name of the current directory. The command starts in that directory, so relative paths keep meaning what they meant on the host. Overlay configuration: - `lowerdir`: the source directory (read-only) @@ -385,7 +385,7 @@ $ ecr ubuntu:noble -- make build ### Read-Write Bind Mount -`--bind-rw ` creates a true read-write bind mount at `/mnt/`. This modifies the host filesystem directly. Use with caution. +`--bind-rw ` creates a true read-write bind mount at `/mnt/`. This modifies the host filesystem directly. Use with caution. When the current directory is mounted this way, the command starts in `/mnt/`. Multiple `--bind-rw` paths can be specified. If a path is specified in both `--bind` and `--bind-rw`, the read-write mount takes precedence.