If i tried to run docker version 24.0 inside a chroot environment i get this
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
478afc919002: Extracting 3.195kB/3.195kB
docker: failed to register layer: remount /, flags: 0x84000: invalid argument.
See 'docker run --help'.
Is there any feature/option to workaround this ? What piece code is responsible for this error?
The chrooting script
#!/bin/bash
export distro=/data/data/com.termux/files/distro/Ubuntu/
#mkdir -p "$distro/dev" "$distro/proc" "$distro/sys"
# Check if directories are already mounted
if [[ "$( su -c mount | grep $distro/dev)" && "$( su -c mount | grep $distro/proc)" && "$( su -cmount | grep $distro/sys)" ]]; then
echo "Directories already mounted"
else
# Mount directories
su -c "mount --rbind /dev/ $distro/dev/" || exit 1
su -c "mount --rbind /dev/pts/ $distro/dev/pts/" || exit 1
su -c "mount --rbind /proc/ $distro/proc/" || exit 1
# su -c "mount binfmt_misc -t binfmt_misc $distro/proc/sys/fs/binfmt_misc" || exit 1
su -c "mount --rbind /sys/ $distro/sys" || exit 1
su -c "mount -t cgroup2 none $distro/sys/fs/cgroup" || exit 1
# su -c "mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup $distro/sys/fs/cgroup"
# su -c "mount --rbind /vendor $distro/vendor" || exit 1
fi
# Chroot
su -c "chroot $distro /bin/env -i \
SHELL=/bin/bash \
PWD=/root \
TERM=xterm-256color \
LOGNAME=root \
HOME=/root \
LANG=C.UTF-8 \
USER=root \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
TMDIR=/tmp/ \
_=/usr/bin/env \
/bin/su - root " || exit 1
# Umount
function umount_dirs(){
su -c "umount $distro/dev/pts" 2>&1 >/dev/null
su -c "umount $distro/dev" 2>&1 >/dev/null
su -c "umount $distro/proc/sys/fs/binfmt_misc" 2>&1 >/dev/null
su -c "umount $distro/proc" 2>&1 >/dev/null
su -c "umount $distro/sys/fs/cgroup" 2>&1 >/dev/null
su -c "umount $distro/sys" 2>&1 >/dev/null
}